sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Can Plugins Create Key Bindings?

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 4 Posters 314 Views 4 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.
    • J Offline
      jrstoup
      last edited by

      I looked in the SketchUp documentation and I can't find what I'm looking for so I thought I would come here.

      What I want to do is bind a custom ruby script to a specific key. For example, I want to bind the F8 key so that when it is pressed a window comes up and says "Congrats, you pressed F8!". Is this possible? If so, what is the API call?

      Thanks.

      1 Reply Last reply Reply Quote 0
      • tbdT Offline
        tbd
        last edited by

        it is not possible. keyboard shortcuts are user decision.

        SketchUp Ruby Consultant | Podium 1.x developer
        http://plugins.ro

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

          If you write a tool that messes with other people's shortcuts then it's a shortcut to becoming 'Mr Unpopular 2012'.
          You might be able to do it on a PC given a convoluted Registry hack to rewrite 'HKEY_CURRENT_USER\Software\Google\SketchUp8\Settings' key/values... BUT even then, unless it's been run before Sketchup ever starts at all, the change will only be apparent after a Sketchup restart.

          However, if you simply want to spot which key has been pressed/release then look at the Tool class - for that's how keys are assigned to functions in a Tool itself...
          http://code.google.com/apis/sketchup/docs/ourdoc/tool.html#onKeyDown
          http://code.google.com/apis/sketchup/docs/ourdoc/tool.html#onKeyUp

          TIG

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

            Here is what I eventually figured out. You can create a ruby script, add it to the plugins menu and then create a shortcut that references that script. However, to create the shortcut you have to go into the menu Window > Preferences > Shortcuts, search for the script and then add it that way.

            So to recap, yes it is possible to bind scripts to keys, however you can't do it with another script. Adding shortcuts can only be done by the user it seems. So now you know.

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

              Of course any user can set a Shortcut Key to any 'tool' [native or scripted], provided that it has an entry that you can access through the dialog's [filtered] list, compiled from the menus and context-menus [being 'active' items as you try to set it, e.g. 'Reverse' for faces is not listed as a potentially key-able item unless you have a face preselected before you open Preferences].

              But your original question suggested you wanted to do it 'in code', which is not possible [or at least practically so].
              πŸ˜•

              TIG

              1 Reply Last reply Reply Quote 0
              • Dan RathbunD Offline
                Dan Rathbun
                last edited by

                Pls move to Developers forum.

                I'm not here much anymore.

                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