Enable Web Inspector in WebDialog on Mac
-
I've been trying to do this for ages, and it's so simple... just like me
so, incase any other Mac users want the full native web inspector in SU, here's my 'how to'
To enable the Web Inspector panel in WebDialog on Mac OSX...
-
Go to ~/Library/Preferences/com.google.sketchupfree[n].plist
-
Open the file with the Property List Editor.app(default) or other
-
Click on the add [+] icon
-
new item name "WebKitDeveloperExtras", then tab
-
set type to boolean, then tab
-
check box, sets this value to true
-
open Sketchup, open a WebDialog, right click in a void and select "Inspect element" to open Inspector
and it even splits off into separate window.... finally john
-
-
Sounds like a good candidate for a new chapter of the "WebDialog: Lost Manual" edition 2.
ThomThom ?
-
Would it be possible to set that from Ruby (and give Mac developers a toggle ?)
if RUBY_PLATFORM =~ /(darwin)/ require('sketchup.rb') module Dev MENU = UI.menu('Plugins').add_submenu('Development') module Safari MENU = Dev;;MENU.add_submenu('Safari') MENUITEMS = {} @@webinspector_enabled = false self.webinspector=(bool) val =( bool ? "true" ; "false" ) @@webinspector_enabled =( bool ? true ; false ) Sketchup.write_default( "", "WebKitDeveloperExtras", val ) end self.webinspector? val = Sketchup.read_default( "", "WebKitDeveloperExtras" ) return @@webinspector_enabled =( val == "true" ? true ; false ) end unless file_loaded?(__FILE__) # init the var @@webinspector_enabled self.webinspector? puts("Safari Dev; Web Inspector enabled = #{@@webinspector_enabled}") unless $VERBOSE.nil? MENUITEMS['Web Inspector']= MENU.add_item('Web Inspector') { # toggle Web Inspector self.webinspector=( !@@webinspector_enabled ) } MENU.set_validation_proc(MENUITEMS['Web Inspector']) { @@webinspector_enabled ? MF_CHECKED ; MF_UNCHECKED } end end # module Safari end # module Dev end # if Mac only file_loaded(__FILE__)
You'll perhaps need to adjust the actual values written to the plist..
if they are 0 || 1 for false and true, then change the val lines (15 and 22,) to:
val =( bool ? 1 : 0 )
and
return @@webinspector_enabled =( val == 1 ? true : false )
.. or similar. (you get the idea?) -
Hi Dan,
been at a fete since i posted,
what you don't get (which would be very useful) is the 'Develop' menu and it's down list.
Can code add a new 'Main Menu' item for webkit to populate? or would I need to do that in the nib file?
javascript debug and the console seem to work.
I'll try and have a play later.
john
-
@driven said:
what you don't get (which would be very useful) is the 'Develop' menu and it's down list.
The code sample is a Ruby script that adds a submenu to the Sketchup "Plugins" menu (not to any Safari menu.)
It may need to run at Sketchup startup in order to add menu items (at least on Windows submenus can be added after startup, but not menu items.)
-
hi Dan,
btw, cheers for your mac interest
I can see what your code does for loading Web Inspector via ruby, but I don't think it needs a Plugins menu item or toggle. It's quite easy to do and undo manually.
Anyone wanting to use WI in or out of SU needs Apple Developer Tools and if they can instal that, than this is a simple extra step.
It's adding the other features associated with the Develop menu that's of interest to me. http://wn.com/Safari_debug_menu
I'll see if I can set context menu items or shortcut keys to work with it, that may be easier than Menu Items.
john
added a link so you can see what I mean. -
I am sure I am doing something stupid, but this isn't working for me.
I have found ~/Library/Preferences/com.sketchup.SketchUp.2016.plist . Opened it with Xcode, made the additional property to the root, saved it. Then nothing. I try to go back to open the .plist file again, and it doesn't let me.... Strange? Any ideas?
-
Tommy, just set it as a global preference and it works for SU and Safari...
defaults write NSGlobalDomain WebKitDeveloperExtras -bool true
paste into Terminal or wrap in %x() from Ruby Console...
john
-
@driven said:
Tommy, just set it as a global preference and it works for SU and Safari...
defaults write NSGlobalDomain WebKitDeveloperExtras -bool true
paste into Terminal or wrap in %x() from Ruby Console...
john
YES! IT WORKS! SO SIMPLE! THANK YOU!
Advertisement