Firing Button with Modifier Key
-
does anyone know: Can a toolbar button be aware of a modifier key being present (pressed)?
i can see it is possible with mouse click, but not from toolbar (at least all my attempts have failed).
-
I don't think it is possible.
I've never managed it - so it is probably impossible -
wow TIG, not even you! really hope some trimble folks start looking at this whole universe!
what of a process like this: click button > script looks to see whether any key is pressed > if within 1 sec no modifier is found > go ahead with the main routine > else...
dreamland?
-
I guess you could hook into the Win32 API (not sure what you got under OSX for that) and detect key presses.
Though, it'd be very unconventional UI - don't think I've seen any applications that has modifier keys for toolbar actions.
-
thanks Thomas, so a ruby script cannot simply 'listen' to key press upon firing?
PS (never mind macs!)
-
@cadfather said:
thanks Thomas, so a ruby script cannot simply 'listen' to key press upon firing?
If you hook into the Win32 API I think it should be possible. But I have no simple examples of that. Anton might know more - think he's doing something like that for his full screen extension.
-
You could probably also write an AutoHotKeys snippet [PC only!] which would spot a click in SketchUp with a key etc, BUT it'd be mucho complicado...
-
if the button you click is a tool, you can watch for modifier keys?
I assume [due to lack of use case] that you want one button for 3 tools [as example]...
create a simple tool with one button...
on click, [activating your tool] start a timer and watch for modifier keys...
if key = a activate x
if key = b activate y
if you run out of time if activate zis that the sort of thing your after?
or have I completely misunderstood yet again...
john
-
There's this, but Windows only and not up-to-date and needs compiled, etc.
-
There is a way, thought it will require that your extension to require AMS Library. Easy to implement.
Here is a snippet:require 'ams_Lib/main' class MyTool def swp_on_key_down(key, val, char) # process... # Return 1 to prevent key from interacting with SU window. # Return anything else to avoid blocking the key. end end AMS;;Sketchup.add_observer(MyTool.new)
Here is the docs for all events you can use: AMS::SketchupObserver
You can monitor/process keyboard press, mouse clicks, and even the mouse wheel rotate/tilt.Windows only!
-
didn't notice the thread had progressed...
@tig said:
You could probably also write an AutoHotKeys snippet [PC only!] which would spot a click in SketchUp with a key etc, BUT it'd be mucho complicado...
ahk is quite good, i can see it possible but not too good for public consumption - with compatibility etc..
@driven said:
if the button you click is a tool, you can watch for modifier keys?
I assume [due to lack of use case] that you want one button for 3 tools [as example]...
create a simple tool with one button...
on click, [activating your tool] start a timer and watch for modifier keys...
if key = a activate x
if key = b activate y
if you run out of time if activate z
is that the sort of thing your after?
or have I completely misunderstood yet again...
johnyes, exactly that.
@jim said:
There's this, but Windows only and not up-to-date and needs compiled, etc.
https://code.google.com/p/eventrelay/will have a look, thanks Jim
@anton_s said:
There is a way, thought it will require that your extension to require AMS Library. Easy to implement.
Here is a snippet:very interesting Anton, will look into it
(where's a Christmas holiday when you need it?!)
Advertisement