by thomthom » Fri Dec 31, 2010 10:53 am
Fortunately webdialogs under windows are click-through. But OSX remains a problem. I'm not happy with having the user remembering to press Ctrl every time they want to interact with the window.
-

thomthom
- Global Moderator
-
- Posts: 17545
- Joined: Tue Nov 13, 2007 12:47 pm
- Location: Trondheim, Norway
- Name: thomthom
- Operating system: Windows
- SketchUp version: 8
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
-
by Dan Rathbun » Fri Dec 31, 2010 1:49 pm
@John ( driven) & ThomThom Try the events in the code below for Safari toolbar WebDialogs. * if the ctrlKey event doesn't work for Safari, perhaps try setting the altKey event to true onMouseIn and false onMouseOut. You may need a onMouseOver="window.focus();" attribute within the body tag, in order for document.activeElement (see body tag's onClick event,) to return the control that is set active by each control's onmouseover event. If you DO, then you'll definately need the window.blur() statement within the body tag's onMouseOut event (otherwise you may not.) - Code: Select all
<html>
<body onMouseIn="window.event.ctrlKey=true"; onMouseOut="window.event.ctrlKey=false; window.blur();" onClick="document.activeElement.click();">
<img class="imgbutton" onmouseover="this.setActive" src="SketchupIcon.png" onClick="callSomeJsFunctionToRubyCallback('params');">
... the rest of your webpage ...
The idea step by step: 1. Sketchup Application Window has focus 2. mouse moves into toolbar webdialog setting window.event.ctrlKey=true (and possibly dialog focus via body onMouseOver. 3. as the mouse moves over controls, each control has a onmouseover="this.setActive" event. 4. when a click occurs anywhere on the page, the body tag's onClick event uses document.activeElement.click to cause active control's onClick event to fire. 5. when the mouse moves out of the toolbar dialog, the body tag's onMouseOut event resets the key event to false, and optionally calls window.blurThe <IMG> tags are given a class "imgbutton" so they can have styles set for borderstyle, etc. ~
-

Dan Rathbun
- Top SketchUcator
-
- Posts: 4069
- Joined: Tue Oct 06, 2009 3:06 am
- Location: Florida, USA
- Name: Dan Rathbun
- Operating system: Windows
- SketchUp version: 8
- License type: Pro
- SketchUp use: education
- Level of SketchUp: Advanced
by thomthom » Fri Dec 31, 2010 2:06 pm
Dan Rathbun wrote:2. mouse moves into toolbar webdialog setting window.event.ctrlKey=true (and possibly dialog focus via body onMouseOver.
Will the mouse event trigger when the webdialog haven't got focus?
-

thomthom
- Global Moderator
-
- Posts: 17545
- Joined: Tue Nov 13, 2007 12:47 pm
- Location: Trondheim, Norway
- Name: thomthom
- Operating system: Windows
- SketchUp version: 8
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
-
by thomthom » Fri Dec 31, 2010 2:09 pm
Jim wrote: <body onMouseOut ="window.blur()"> On Windows, it sends the main SU window and everything else to the back.
How odd...
-

thomthom
- Global Moderator
-
- Posts: 17545
- Joined: Tue Nov 13, 2007 12:47 pm
- Location: Trondheim, Norway
- Name: thomthom
- Operating system: Windows
- SketchUp version: 8
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
-
by Dan Rathbun » Fri Dec 31, 2010 2:18 pm
thomthom wrote:Dan Rathbun wrote:2. mouse moves into toolbar webdialog setting window.event.ctrlKey=true (and possibly dialog focus via body onMouseOver.
Will the mouse event trigger when the webdialog haven't got focus?
it DOES on Win32 w/ IE 7
-

Dan Rathbun
- Top SketchUcator
-
- Posts: 4069
- Joined: Tue Oct 06, 2009 3:06 am
- Location: Florida, USA
- Name: Dan Rathbun
- Operating system: Windows
- SketchUp version: 8
- License type: Pro
- SketchUp use: education
- Level of SketchUp: Advanced
by driven » Fri Dec 31, 2010 2:21 pm
hi Dan, Thom, Jim, all I've been trying all sorts of things to 'avoid' giving the WebDialog 'focus' while still having it send actions. this is what happens with SU native NSPanels (used for SU toolbars) and also for some of the NSWindows used for different preferences and the NS(WebView)Window used by Instructor, but not the NS(WebView)Window used by WebDialog. holding down the "cmd"(apple) key, invokes this behavior ( no focus, but active) on any window/panel inside so far the best/simplest way I've come up with is add to an 'aid memoir', using background colours and text..... but I'll keep trying john cmd_key solution.jpg
Please, register (free) to access all the attachments on the forums.
-
driven
- Top SketchUcator
-
- Posts: 1407
- Joined: Fri May 01, 2009 11:50 pm
- Name: John
- Operating system: Mac
- SketchUp version: 8
- License type: Pro
- SketchUp use: engineering and mechanical design
- Level of SketchUp: Intermediate
by Dan Rathbun » Fri Dec 31, 2010 2:23 pm
thomthom wrote:Jim wrote: <body onMouseOut ="window.blur()"> On Windows, it sends the main SU window and everything else to the back.
How odd...
yea I tried with a modified test dialog John sent me (I added buttons and some key displays.) SelectionInfo.zip
Please, register (free) to access all the attachments on the forums.
-

Dan Rathbun
- Top SketchUcator
-
- Posts: 4069
- Joined: Tue Oct 06, 2009 3:06 am
- Location: Florida, USA
- Name: Dan Rathbun
- Operating system: Windows
- SketchUp version: 8
- License type: Pro
- SketchUp use: education
- Level of SketchUp: Advanced
by Dan Rathbun » Fri Dec 31, 2010 2:30 pm
Hey John ... you talk about NS windows made me think of the 9th arg to WebDialog.new :mac_only_use_nswindow
You might need to use a settings Hash to use it. If you do, the key for the 3rd arg is :preferences_key not 'key'
You should also use Symbol keys not String keys, as the Hash argument is cranky.
-

Dan Rathbun
- Top SketchUcator
-
- Posts: 4069
- Joined: Tue Oct 06, 2009 3:06 am
- Location: Florida, USA
- Name: Dan Rathbun
- Operating system: Windows
- SketchUp version: 8
- License type: Pro
- SketchUp use: education
- Level of SketchUp: Advanced
by thomthom » Fri Dec 31, 2010 2:35 pm
Dan Rathbun wrote:it DOES on Win32 w/ IE 7
Yea but windows doesn't have the click-through issue. I was thinking since click events would not register under OSX until the window had gotten focus, then maybe mouse events would not trigger either. ...I really need to find that box with my Mac... ...ugh, the hurdles of moving...
-

thomthom
- Global Moderator
-
- Posts: 17545
- Joined: Tue Nov 13, 2007 12:47 pm
- Location: Trondheim, Norway
- Name: thomthom
- Operating system: Windows
- SketchUp version: 8
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
-
by driven » Sun Jan 02, 2011 1:51 am
an update,
holding the cmb key down is great for tool swaps and input button clicks, but locking it down means you can't use numerical input boxes...
I didn't realise that cmd 1,2,3,4,5,6,7,8,9,0 are all shortcut keys, so holding down the key manually is the best option....
john
-
driven
- Top SketchUcator
-
- Posts: 1407
- Joined: Fri May 01, 2009 11:50 pm
- Name: John
- Operating system: Mac
- SketchUp version: 8
- License type: Pro
- SketchUp use: engineering and mechanical design
- Level of SketchUp: Intermediate
by Dan Rathbun » Tue Jan 04, 2011 10:51 am
thomthom wrote:I've been searching for ways to manipulate windows under OSX like one can do under Windows with the Win32 API - but I never find anything.  RubyCocoait's included with OSX since v10.5 “Leopard” ?? EDIT: Here's the RubyCocoa SourceForge page. I've seen Ruby scripts that had: require 'Cocoa' or similar at the top. There is a potential pitfall looming for Sketchup cross-platform scripting, in that Apple intends to replace MRI Ruby, with MacRuby. It would not be bad if we had all the same UI classes in a "WinRuby" that MacRuby has.
-

Dan Rathbun
- Top SketchUcator
-
- Posts: 4069
- Joined: Tue Oct 06, 2009 3:06 am
- Location: Florida, USA
- Name: Dan Rathbun
- Operating system: Windows
- SketchUp version: 8
- License type: Pro
- SketchUp use: education
- Level of SketchUp: Advanced
by thomthom » Tue Jan 04, 2011 11:11 am
Ok - something to look into. I hope that allows you to modify existing windows, not sure create your own. (Though creating your own would be cool too.)
-

thomthom
- Global Moderator
-
- Posts: 17545
- Joined: Tue Nov 13, 2007 12:47 pm
- Location: Trondheim, Norway
- Name: thomthom
- Operating system: Windows
- SketchUp version: 8
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
-
by thomthom » Tue Jan 04, 2011 11:12 am
Dan Rathbun wrote:There is a potential pitfall looming for Sketchup cross-platform scripting, in that Apple intends to replace MRI Ruby, with MacRuby. It would not be bad if we had all the same UI classes in a "WinRuby" that MacRuby has.
mhm - some wrapper to bridge it all.
-

thomthom
- Global Moderator
-
- Posts: 17545
- Joined: Tue Nov 13, 2007 12:47 pm
- Location: Trondheim, Norway
- Name: thomthom
- Operating system: Windows
- SketchUp version: 8
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
-
by Dan Rathbun » Wed Jan 05, 2011 5:46 pm
thomthom wrote:Dan Rathbun wrote:There is a potential pitfall looming for Sketchup cross-platform scripting, in that Apple intends to replace MRI Ruby, with MacRuby. It would not be bad if we had all the same UI classes in a "WinRuby" that MacRuby has.
mhm - some wrapper to bridge it all.
Yes the 'wrappings' would need to follow (as closely as possible,) those defined in HotCocoa for MacRuby. Note that in the example on the HotCocoa introduction page, they are showing the use of a window() constructor method. What they don't actually show is that farther up at the beginning of the Ruby module block, is that there must be an include HotCocoa (or some other mixin module,) that brings that window() method into the current namespace. I usually don't like to do this, instead prefering to call the method using fullnamespace qualification. Less chance then of an accidental override of methods that are imported into your namespace. In this example, I would probably wish to have a window() method in my namespace that returns the instance handle to the window object ( @win,) so I'd think most times it's not really that convenient to include entire complex libraries, into a custom namespace.
-

Dan Rathbun
- Top SketchUcator
-
- Posts: 4069
- Joined: Tue Oct 06, 2009 3:06 am
- Location: Florida, USA
- Name: Dan Rathbun
- Operating system: Windows
- SketchUp version: 8
- License type: Pro
- SketchUp use: education
- Level of SketchUp: Advanced
Return to Developers' Forum
|