Keyboard Shortcuts in MapBasic for 64-bit MapInfo

269 views
Skip to first unread message

gregs...@gmail.com

unread,
May 31, 2017, 1:09:17 AM5/31/17
to MapInfo-L
In 32-bit MapBasic/MapInfo, I had code that created a menu with keyboard shortcuts using the /W%XXX syntax, as follows:

create menu "Pea&k" as
  "&Get Map /W%120"        calling GetMap,

This allowed me to simply hit the F9 key to activate the MapBasic routine GetMap, instead of the 3-key combo Alt-K-G.  This single key shortcut was a great convenience.

In 64-bit MapInfo, my code still runs in the "Legacy" Ribbon, but the keyboard shortcuts no longer work.  So I started porting my code to use the RibbonLib library so it can be integrated into the new ribbon interface. When using the RBNGroupAddButton() function, I can set one-character keyboard shortcuts, for example:

 nCtrlIdx = RBNGroupAddButton("GetMap", "Get Map", "G", sTabName, sGroupName)

This allows me to replicate the three-key combos from my old code. But the third argument of RBNGroupAddButton will not take a code for a single key.  I have tried "F9", "/W%120", "%120", and other combinations.

I have also looked at the Command Editor tool, which allows me to set keyboard shortcuts for built-in MapInfo commands, but my custom ribbon commands do not appear in that interface for assignment to keys like F9.

Does anyone know of a way to get a single function key press to run a MapBasic menu/ribbon command in 64-bit MapInfo?  Thanks for any suggestions.

Peter Horsbøll Møller

unread,
May 31, 2017, 2:44:54 AM5/31/17
to mapi...@googlegroups.com

When you have added the control to the ribbon using RBNGroupAddButton() you can use this procedure to assign a shortcut key to the control:

 

Sub RBNControlSetKeyGestureIdx(    ByVal nElementIdx As Integer

                                 , ByVal sGesture As String       'For example "Ctrl+Y", "Alt+Ctrl+Y"

                                 )

 

So you statement would look like:

Call RBNControlSetKeyGestureIdx(nCtrlIdx, "F9")

 

I hope this helps.

PS: Apparently MapInfo Pro doesn’t add the shortcut to the Tooltip so you need to do this yourself

 

Peter Horsbøll Møller

Pitney Bowes

--
--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en

---
You received this message because you are subscribed to the Google Groups "MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapinfo-l+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.




gregs...@gmail.com

unread,
May 31, 2017, 12:54:17 PM5/31/17
to MapInfo-L
Thank you very much for your help. The "KeyGesture" was exactly what I was looking for--I was just unaware of that term.  I have gotten that solution to work fine--I appreciate your help,

--Greg
Reply all
Reply to author
Forward
0 new messages