MapInfo Pro Developers User Group

 View Only
Expand all | Collapse all

MapBasic to remove button from ribbon tab

  • 1.  MapBasic to remove button from ribbon tab

    Posted 07-08-2019 22:01
    I want to run a MapBasic app which will remove standard buttons from the ribbon tab, specifically the Save Workspace and Save Workspace As split buttons.

    The reason I want to do this is I want to replace them with my own buttons, which run some checks on the WOR file after I've saved it.

    How can I remove these buttons with MapBasic?

    Thanks Kalu

    ------------------------------
    Kalu Ribush
    Senior Mapping Specialist
    Department of Economic Development, Jobs, Transport and Resources (DEDJTR)
    Melbourne NT
    ------------------------------


  • 2.  RE: MapBasic to remove button from ribbon tab

    Employee
    Posted 07-09-2019 14:47
    Hi Kalu

    Do you want  to replace the control  completely or just assign a new handler to the existing control?

    For the first, you could hide the existing control and place your new control after or before.

    for the later, just assign a new MBXHandler to the control

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



  • 3.  RE: MapBasic to remove button from ribbon tab

    Posted 07-09-2019 19:19
    Hi Peter, either approach would work for me.

    I'm not sure how to go about replacing the handler for the existing control. Perhaps you could explain that further.

    I was trying to hide the existing buttons.  I thought it was something like:

           Call RBNControlSetVisibility(TAB_HOME,TAB_GROUP_HOME_FILE,"SaveWorkspaceButton",False)

    But that doesn't seem to work. Perhaps I don't have the button name correct?

    Thanks Kalu

    ------------------------------
    Kalu Ribush
    Senior Mapping Specialist
    Department of Economic Development, Jobs, Transport and Resources (DEDJTR)
    Melbourne NT
    ------------------------------



  • 4.  RE: MapBasic to remove button from ribbon tab

    Posted 07-10-2019 01:17
    Hi Kalu,

    I needed to hide some controls some time back, to find out the names of the controls was difficult until I found a tool that prints out a lot of info about the ribbon to a file.

    What you need is this to turn off the Save Workspace SplitButton.

    Call RBNControlSetVisibility("TabHome", "HomeFile", "HomeSaveWorkspaceSplitButton", False)

    I can't seem to upload the file think my workplace blocks it, will try it from home.

    Regards
    Andrew

    ------------------------------
    Andrew Niebling
    Systems Administrator (GIS)
    Queensland Rail Ltd
    Brisbane
    ------------------------------



  • 5.  RE: MapBasic to remove button from ribbon tab

    Posted 07-10-2019 02:13
    Thanks Andrew, that worked. 

    It would be great if there was some documention on this on the community site somewhere. 

    Cheers

    ------------------------------
    Kalu Ribush
    Senior Mapping Specialist
    Department of Economic Development, Jobs, Transport and Resources (DEDJTR)
    Melbourne NT
    ------------------------------



  • 6.  RE: MapBasic to remove button from ribbon tab

    Posted 07-10-2019 02:48
    Hi Andrew,

    Did you try zipping the file before uploading?  Only certain file types are accepted, and zip seems to be one of them (but not .MBX).

    ------------------------------
    James Nolet
    Dooley Mitchell & Morrison Pty Ltd
    ------------------------------



  • 7.  RE: MapBasic to remove button from ribbon tab

    Employee
    Posted 07-10-2019 12:24
    I second that request, Kalu :-)

    The missing documentation is starting to become an issue, not only for the RibbonLib but for the MapBasic Common Libraries in general.

    What type of documentation would be most helpful?

    1. A general description of each function
    2. Samples 
    3. Both

    I'm not making any promises but just trying to understand what you would like/need/prefer.

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



  • 8.  RE: MapBasic to remove button from ribbon tab

    Posted 07-10-2019 20:01
    Hi Peter,

    I'd love to see some support document which lists how to add, insert, remove, modify, etc, controls on the ribbon tabs.  I know some of this exists in documents you've created, but I'm not sure it's comprehensive.

    Some examples of the mapbasic commands would be really helpful.

    In order to remove/alter existing ribbon controls, I'd like to see a full list of the control names.

    It's a bit confusing searching the MapBasic application help. It has topics on altering button pads, which relate to the old 32bit style toolbars which will be shown in the Legacy tab, but it doesn't contain any help on modify the ribbon controls.   I understand you have to use the commands related to the ribbon library, but there's nothing in the application help documents which could help a user with this.

    Regards

    ------------------------------
    Kalu Ribush
    Senior Mapping Specialist
    Department of Economic Development, Jobs, Transport and Resources (DEDJTR)
    Melbourne NT
    ------------------------------



  • 9.  RE: MapBasic to remove button from ribbon tab

    Posted 07-10-2019 22:31
    Hi James,

    I did try zipping the files up but just get this error:

    Failed to upload: Ribbon_Tools.zip

    I have put them on my readycloud device.

    The tool which will print the Ribbon elements and statements to a txt file is available from the link below, Thanks to Peter who I originally got the mapbasic statements from.

    Ribbon_Tools.zip

    I certainly agree with Kalu's previous post, when it comes to the Ribbon there is very little out there. I am currently trying to set up a toggle button to turn on/off a seamless aerial layer but i can find no documentation or working examples of this anywhere.

    Regards
    Andrew

    ------------------------------
    Andrew Niebling
    Systems Administrator (GIS)
    Queensland Rail Ltd
    Brisbane
    ------------------------------



  • 10.  RE: MapBasic to remove button from ribbon tab

    Posted 07-10-2019 23:40
    Hi Andrew

    I've written some code for a rather elaborate ribbon toolbar with shortcuts to many different layers.  I can share some code with you if you like.

    You might be interested in using the Personal Favourites tool, on the community download site, which you can easily customise with shortcuts to your favourite layers.

    Cheers

    ------------------------------
    Kalu Ribush
    Senior Mapping Specialist
    Department of Economic Development, Jobs, Transport and Resources (DEDJTR)
    Melbourne NT
    ------------------------------



  • 11.  RE: MapBasic to remove button from ribbon tab

    Posted 07-14-2019 18:18
    Hi Kalu,

    I am interested to see what you've done with your Ribbon toolbar, will try out the Favourites Tool as well thanks.

    Regards
    Andrew


    ------------------------------
    Andrew Niebling
    Systems Administrator (GIS)
    Queensland Rail Ltd
    Brisbane
    ------------------------------



  • 12.  RE: MapBasic to remove button from ribbon tab

    Employee
    Posted 08-29-2019 04:45
    Hi Kalu

    I found an old email which made me remember that I never really responded to one part of your question.
    The RibbonLib has a couple of methods that will let you loop through the current ribbon and print out details of the tabs, the groups, and the controls.

    To get a list of the names and their types, simply call the method RBNLoop.

    It will create a file called "Ribbon Elements.txt" in your application folder with content like this:
    Tab 0 is named 'TabHome' but shown as 'HOME'
    Tab Group 0 is named 'HomeFile' but shown as 'File'
    Control 0 is named 'HomeFileOpenGallerySplitButton' but shown as 'Open' and Control Type is 10 (SplitButton)
    SplitButton has 5 Groups/controls
    SplitButton Control 0 is named 'WorkspaceTable' but shown as 'Workspaces, Tables, Programs' and Control Type is 11 (DropDownMenuGroup)
    DropDownMenu Control has 7 Controls
    DropDownMenu Control 0 is named 'FileOpenWorkspaceButton' but shown as 'Open Workspace' and Control Type is 1 (Button)
    DropDownMenu Control 1 is named 'FileAddWorkspaceButton' but shown as 'Add Workspace' and Control Type is 1 (Button)
    DropDownMenu Control 2 is named 'FileOpenTableButton' but shown as 'Table' and Control Type is 1 (Button)
    DropDownMenu Control 3 is named 'FileImportButton' but shown as 'Import' and Control Type is 1 (Button)

    You can also call a similar method, called RBNLoopCreateRibbonStatements, it will create statements to replicate the ribbon. Admitted, I haven't tested this part a lot so there might be some tweaks that make it fail. But it might give you an overview of the different statements for creating different control types. The output in the file "Ribbon Statements.txt" looks like this:
    Call DEBUGPrint("TabHome")
    Call DEBUGPrint("TabHome")
    nCtrlIdx = RBNAddTab("TabHome", "HOME", "H")
    '------------------------------
    Call DEBUGPrint("   HomeFile")
    nCtrlIdx = RBNTabAddGroup("HomeFile", "File", "TabHome")

    nCtrlIdx = RBNGroupAddControl("HomeFileOpenGallerySplitButton", "Open", "O", 10, "TabHome", "HomeFile")
    Call RBNControlSetIconsIdx(nCtrlIdx, 3, "pack://application:,,,/MapInfo.StyleResources;component/Images/Application/openWorkspace_16x16.png", "pack://application:,,,/MapInfo.StyleResources;component/Images/Application/openWorkspace_32x32.png")
    nCtrlIdx = RBNSplitButtonAddGroup("WorkspaceTable", "Workspaces, Tables, Programs", "TabHome", "HomeFile", "HomeFileOpenGallerySplitButton")
    nCtrlIdx = RBNSplitButtonGroupAddControl("FileOpenWorkspaceButton", "Open Workspace", "O", 1, "TabHome", "HomeFile", "HomeFileOpenGallerySplitButton", "WorkspaceTable") Call RBNControlSetIconsIdx(nCtrlIdx, 3, "pack://application:,,,/MapInfo.StyleResources;component/Images/Application/openWorkspace_16x16.png", "pack://application:,,,/MapInfo.StyleResources;component/Images/Application/openWorkspace_32x32.png")
    Call RBNControlSetCmdIDIdx(nCtrlIdx, 132) nCtrlIdx = RBNSplitButtonGroupAddControl("FileAddWorkspaceButton", "Add Workspace", "O", 1, "TabHome", "HomeFile", "HomeFileOpenGallerySplitButton", "WorkspaceTable")
    Call RBNControlSetIconsIdx(nCtrlIdx, 3, "pack://application:,,,/MapInfo.StyleResources;component/Images/Application/insertWorkspace_16x16.png", "pack://application:,,,/MapInfo.StyleResources;component/Images/Application/insertWorkspace_32x32.png") Call RBNControlSetCmdIDIdx(nCtrlIdx, 108)


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