sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Firing Button with Modifier Key

    Scheduled Pinned Locked Moved Developers' Forum
    11 Posts 6 Posters 568 Views 6 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • CadFatherC Offline
      CadFather
      last edited by

      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).

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        I don't think it is possible. 😞
        I've never managed it - so it is probably impossible πŸ˜‰

        TIG

        1 Reply Last reply Reply Quote 0
        • CadFatherC Offline
          CadFather
          last edited by

          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?

          1 Reply Last reply Reply Quote 0
          • thomthomT Offline
            thomthom
            last edited by

            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.

            Thomas Thomassen β€” SketchUp Monkey & Coding addict
            List of my plugins and link to the CookieWare fund

            1 Reply Last reply Reply Quote 0
            • CadFatherC Offline
              CadFather
              last edited by

              thanks Thomas, so a ruby script cannot simply 'listen' to key press upon firing?

              PS (never mind macs!) πŸ˜‰

              1 Reply Last reply Reply Quote 0
              • thomthomT Offline
                thomthom
                last edited by

                @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.

                Thomas Thomassen β€” SketchUp Monkey & Coding addict
                List of my plugins and link to the CookieWare fund

                1 Reply Last reply Reply Quote 0
                • TIGT Offline
                  TIG Moderator
                  last edited by

                  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... πŸ˜’

                  TIG

                  1 Reply Last reply Reply Quote 0
                  • D Offline
                    driven
                    last edited by

                    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...

                    john

                    learn from the mistakes of others, you may not live long enough to make them all yourself...

                    1 Reply Last reply Reply Quote 0
                    • J Offline
                      Jim
                      last edited by

                      There's this, but Windows only and not up-to-date and needs compiled, etc.

                      Link Preview Image
                      Google Code Archive - Long-term storage for Google Code Project Hosting.

                      favicon

                      (code.google.com)

                      Hi

                      1 Reply Last reply Reply Quote 0
                      • A Offline
                        Anton_S
                        last edited by

                        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!

                        1 Reply Last reply Reply Quote 0
                        • CadFatherC Offline
                          CadFather
                          last edited by

                          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...
                          john

                          yes, 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?!)

                          1 Reply Last reply Reply Quote 0
                          • 1 / 1
                          • First post
                            Last post
                          Buy SketchPlus
                          Buy SUbD
                          Buy WrapR
                          Buy eBook
                          Buy Modelur
                          Buy Vertex Tools
                          Buy SketchCuisine
                          Buy FormFonts

                          Advertisement