MapInfo Pro Developers User Group

 View Only
  • 1.  Adding Multiple Key Gestures to Control Button

    Posted 04-17-2025 13:27
    Edited by Peter Møller 04-30-2025 01:11
      |   view attached

    Hello, I have created a simple script to automatically select and find the next item in a table. Is there a way to add multiple key gestures to a single button, in this case to allow users to select and find the previous item? Better yet, is it possible to assign key gestures to a running script that does not require a Ribbon control? This way the script would be in the background, waiting for specific input to carry out a procedure. 

    Include "Mapbasic.def"
    Include "RibbonControls.def"
    '=============================================================================================
    Declare Sub Main
    Declare Sub Test_Sub
    Declare Sub EndHandler
    '=============================================================================================
    Sub Main()
    
    Set Ribbon Tab TAB_SPATIAL
        Group "grpTest" Caption ""
        Controls ( Add
          Control "Testing" Caption "Review"
        Type CTRL_TYPE_BUTTON
          Size Large
          Properties(
          PROPERTY_CALLINGHANDLER : "Test_Sub",
          PROPERTY_KEYGESTURE: "Ctrl+Alt+F",
          PROPERTY_LARGEICON : MI_IMG_APP_RUNMAPBASIC_32
          )
          )
         
    End Sub
    '=============================================================================================
    Sub Test_Sub
    OnError goto ErrorOccured
    
    Dim myrow as integer
    If SelectionInfo(SEL_INFO_NROWS) = 0 Then 
      select obj from "ReviewTable" where RowID = 1
      Set Map Zoom Entire Selection
    Else
      myrow = CommandInfo(CMD_INFO_ROWID)
      select obj from "ReviewTable" where RowID = myrow + 1
      Set Map Zoom Entire Selection 
    End If
    
    Exit Sub
    ErrorOccured:
      Note Error$()
    End Sub
    '=============================================================================================
    Sub EndHandler
    end sub
    '=============================================================================================



    ------------------------------
    Brandon Shepherd
    Knowledge Community Shared Account
    Shelton CT
    ------------------------------



  • 2.  RE: Adding Multiple Key Gestures to Control Button

    Employee
    Posted 04-24-2025 03:03
    Edited by Peter Møller 04-24-2025 03:03

    Hey Brandon

    I wonder if you can use the CommandInfo() function to determine if the user held down the Ctrl or Shift key when they clicked on the control?

    CMD_INFO_SHIFT: Logical value: TRUE if the user held down the Shift key while clicking.
    CMD_INFO_CTRL: Logical value: TRUE if the user held down the Ctrl key while clicking.

    I think it was designed to work with ToolButtons so I'm unsure if it works with any controls/buttons.

    PS: But that might conflict when the keyboard shortcuts...

    ------------------------------
    Peter Horsbøll Møller
    Principal Presales Consultant | Distinguished Engineer
    Precisely | Trust in Data
    ------------------------------



  • 3.  RE: Adding Multiple Key Gestures to Control Button

    Posted 04-29-2025 16:47
    Edited by Brandon Shepherd 04-29-2025 17:01

    Thanks Peter, 

    I think the CommandInfo() feature is limited to toolbuttons, and control buttons themselves can only have one key gesture. 

    I've been experimenting but having trouble with the other Ribbon Control Properties beyond the simple ones here. In order to get the CommandInfo() function to work I believe I need to use a tool button. However, I cant seem to set certain Properties that rely on Icons.def. To start simple I am trying to set the PROPERTY_CURSOR to MI_CURSOR_CROSSHAIR. This returns a message stating only "An Unknown Error has Occurred". Likewise trying "MI_CURSOR_CROSSHAIR" or 138 results the same. 

    I had similar experience with other properties. One I appear to have working is the DRAWMODE, using what would be the same method for setting a cursor. PROPERTY_DRAWMODE : DM_CUSTOM_POLYGON

    I know the RibbonControls.def now has its own set of images, but are all the new Properties intended to work with Icons.def where needed? 



    ------------------------------
    Brandon Shepherd
    Knowledge Community Shared Account
    Shelton CT
    ------------------------------



  • 4.  RE: Adding Multiple Key Gestures to Control Button

    Employee
    Posted 04-30-2025 01:10

    Hey Brandon

    I can see that for the cursor, we have two parameters:

    'IRibbonToolButtonControl
    Define PROPERTY_CURSOR                      "Cursor" 'string
    Define PROPERTY_CURSORID                    "CursorID" 'Integer

    You should be using PROPERTY_CURSORID for the defines as they represent IDs.

    The string-based property is for a cursor file.



    ------------------------------
    Peter Horsbøll Møller
    Principal Presales Consultant | Distinguished Engineer
    Precisely | Trust in Data
    ------------------------------



  • 5.  RE: Adding Multiple Key Gestures to Control Button

    Posted 05-01-2025 14:34

    Ah, simple enough. Thank you.



    ------------------------------
    Brandon Shepherd
    Knowledge Community Shared Account
    Shelton CT
    ------------------------------