MapInfo Pro

Expand all | Collapse all

Using Toolbutton on browser window

  • 1.  Using Toolbutton on browser window

    Posted 06-26-2019 18:55
    ​The documentation for CommandInfo indicates that Toolbutton can be used on browser windows (e.g. CMD_INFO_X/Y should return c​olumn or row).  What is needed to make this work?  After clicking toolbutton, with the browser window in front, the cursor still just changes to editing table fields in the browser window.

    Thanks,
    Mitchel

    ------------------------------
    Mitchel Fielding
    Knowledge Community Shared Account
    ------------------------------


  • 2.  RE: Using Toolbutton on browser window

    Posted 06-26-2019 19:50
    Hi Mitchel,

    It would help to know what you are trying to achieve with your custom tool button.

    ------------------------------
    Simon Emmanuel
    Spatial Solutions Manager
    Salmat Digital
    Prestons
    ------------------------------



  • 3.  RE: Using Toolbutton on browser window

    Posted 06-26-2019 20:28
    ​Hi Simon, I want to present a pop-up dialog box with fields that depend on the row that was selected in the browser window.

    I'm currently doing this with a map window, but want a mechanism to provide the same functionality for records that don't have graphical data.

    Thanks,

    ------------------------------
    Mitchel Fielding
    Knowledge Community Shared Account
    ------------------------------



  • 4.  RE: Using Toolbutton on browser window

    Pitney Bowes
    Posted 06-27-2019 00:43
    Hi @Mitchel Fielding, ​​

    Yes this would be possible, there's a couple of ways of approaching this, here's one idea:
    1. Use CommandInfo(CMD_INFO_Y) to extract the row that the User click on
    2. Use BrowserInfo() function to extract specific details about the position of the cursor
    3. Use Fetch to then get the corresponding record. e.g. Fetch Rec n where N is the RowID of the specific record
    4. Setup a loop to extract the values for each field of this record. For each field in the record you'll need to query to extract the data. The loop can be setup to be dynamic based on the number of fields (check out TableInfo([Table_Name], TAB_INFO_NCOLS)). There's an example of this at the end of the "Fetch Statement" description in the MapBasic help file
    5. Build a dialogue box with the appropriate controls, prepopulate controls with the values extracted as part of Step 4

    Hope this helps!

    Thanks, Ashley

    ------------------------------
    Ashley Crane
    Regional Director, Software Support
    Pitney Bowes
    ------------------------------



  • 5.  RE: Using Toolbutton on browser window

    Posted 06-27-2019 03:04
    I did something similar but using the selected cell instead of a custom tool.
    My feature was accessed via the Browser Context menu calling this procedure.

    Basically what it does is to filter the browser based on the selected value.
    Notice that I'm using BrowserInfo to detect which cell has been selected.

    Sub TABHFilterBrowserCurrentCell

    Dim nWID, nRow, nCol As Integer,
       sTab, sCol, sCmd As String,
       sValue As String,
       fValue As Float,
       nValue As Integer


    nWID = FrontWindow()
    nRow = BrowserInfo(nWID, BROWSER_INFO_CURRENT_ROW)
    nCol = BrowserInfo(nWID, BROWSER_INFO_CURRENT_COLUMN)
    sTab = WindowInfo(nWID, WIN_INFO_TABLE)
    sCol = ColumnInfo(sTab, "COL" & (nCol + 1), COL_INFO_NAME)


    Do Case ColumnInfo(sTab, sCol, COL_INFO_TYPE)
      Case COL_TYPE_CHAR
        sValue = BrowserInfo(nWID, BROWSER_INFO_CURRENT_CELL_VALUE)
        sCmd = "Where (" & sCol & " = " & Chr$(34) & sValue & Chr$(34) & ")"

      Case COL_TYPE_DECIMAL, COL_TYPE_FLOAT
        fValue = BrowserInfo(nWID, BROWSER_INFO_CURRENT_CELL_VALUE)
        sCmd = "Where (" & sCol & " = " & DeformatNumber$(Format$(fValue, "#.##########")) & ")"

      Case COL_TYPE_INTEGER, COL_TYPE_SMALLINT
        nValue = BrowserInfo(nWID, BROWSER_INFO_CURRENT_CELL_VALUE)
        sCmd = "Where (" & sCol & " = " & Str$(nValue) & ")"

      Case Else
        Call RBNNotificationShow("WindowHelper", GetResItemStr("ERR_ONLY_CHAR_AND_NUM_COLS_SUPPORTED"), Notify_Error, 5000)
        Exit Sub

    End Case
    sCmd = "Set Browse" & " Window " & nWID & " Filter " & sCmd Call DEBUGPrint(sCmd)
    Run Command sCmd


    End Sub

    ------------------------------
    Peter Horsbøll Møller
    Pitney Bowes
    ------------------------------



  • 6.  RE: Using Toolbutton on browser window

    Posted 06-27-2019 03:23
    Thanks ​Peter, that's a good alterative if I can't get the custom toolbutton working.

    ------------------------------
    Mitchel Fielding
    Knowledge Community Shared Account
    ------------------------------



  • 7.  RE: Using Toolbutton on browser window

    Posted 06-27-2019 03:21
    ​Thanks Ashley, the problem I seem to be having is getting the toolbutton action to recognise the click in the browser window at all.  The ToolButton handler doesn't trigger at all if I click within the browser window as the front window.  Is there a specific parameter setting in the Create ButtonPad statement or elsewhere that's needed?

    Toolbutton Calling

    Edit_Asset

    ID PB_EDIT

    Icon 146

    Cursor MI_Cursor_ARROW

    Drawmode DM_Custom_Point

     HelpMsg "\nEdit Asset"


    I'm using MapInfo v15, but compiling to V12.5.

    Thanks,



    ------------------------------
    Mitchel Fielding
    Knowledge Community Shared Account
    ------------------------------



  • 8.  RE: Using Toolbutton on browser window

    Posted 06-29-2019 01:17
    ​Is anyone else seeing similar behaviour for a Toolbutton buttonpad?  With the following handler routine:

    Sub Test_Sub
     Note WindowInfo(FrontWindow(), WIN_INFO_TYPE)
    End Sub

    There is a response when clicking in a Map window, but no response when clicking in a browser window.
    This happens whether I compile with v12.5 or v15

     



    ------------------------------
    Mitchel Fielding
    Knowledge Community Shared Account
    ------------------------------



  • 9.  RE: Using Toolbutton on browser window

    Posted 06-30-2019 04:04
    Hi Micthel,

    I believe ToolButton only works on map windows, as its meant to represent a Tool like Rectangle or Radius (correct if I'm wrong PB Experts).

    You could use a PushButton instead. After making a selection or activating a window, you can then press the button to return the Win Type.

    Thanks

    ------------------------------
    Simon Emmanuel
    Spatial Solutions Manager
    Salmat Digital
    Prestons
    ------------------------------



  • 10.  RE: Using Toolbutton on browser window

    Pitney Bowes
    Posted 06-30-2019 21:19
    Hi Mitchel & Simon,

    I can replicate this behaviour (Toolbutton not returning click on Browser window). I'm not an expert on this MapBasic statement & have only seen this applied to a custom tool for a Map window, agree with the comments from Simon.

    Regards,
    Ashley

    ------------------------------
    Ashley Crane
    Regional Director, Software Support
    Pitney Bowes
    ------------------------------



  • 11.  RE: Using Toolbutton on browser window

    Posted 06-30-2019 22:05
    ​Thanks for the feedback Simon & Ashley, it sounds like this functionality is not available.  The v12.5 Reference for the CommandInfo() function specifies behaviour with a Browser window, which sent me down this track, but I'll take another approach.  Thanks again for your help.

    Mitchel

    ------------------------------
    Mitchel Fielding
    Knowledge Community Shared Account
    ------------------------------



  • 12.  RE: Using Toolbutton on browser window

    Pitney Bowes
    Posted 07-01-2019 01:31
      |   view attached

    ​Hi Mitchel,

    I'm not sure why it may not work with a custom tool button, but taking a look at the MapBasic Reference guide, I found reference to using the ToolHandler procedure which works in conjunction with a special ToolButton. The button associated with a ToolHandler procedure is restricted; in that you cannot use custom icons or drawing modes with the ToolHandler's button.​

    There is a simple example program provided in the MapBasic v12.5 Reference Guide which demonstrates how to set up the ToolHandler procedure that will be called if you select the MapBasic tool, then click on a Map, Browser, or Layout window. I have attached the example program - please see attached zip file which contains the compiled .MBX tool and .MB file.

    When the attached tool is run in MapInfo Pro, a button which looks like a crosshair or plus symbol will appear in the toolbar. If you click on this button to activate the tool, the mouse cursor should transform to reflect this symbol, then if you click on any row/column in the browser window it will return the specific column ID and row ID number relative to where you clicked.

    For further details about the ToolHandler procedure, please see pages 650-651 of the MapBasic v12.5 Reference Guide. Hope this somewhat helps! :)



    ------------------------------
    Dave Kuo
    Pitney Bowes Australia Pty Ltd
    Australia
    ------------------------------

    Attachment(s)

    zip
    BrowserClickTestv15.zip   808B 1 version


  • 13.  RE: Using Toolbutton on browser window

    Posted 07-01-2019 19:22
    Thanks Dave, that explains the CommandInfo() references and provides a very interesting alternative since a full custom button isn't an option.  If I could move it into my custom menu bar it would be perfect!  Great find :-)

    Thanks,
    Mitchel​

    ------------------------------
    Mitchel Fielding
    Knowledge Community Shared Account
    ------------------------------