SetToolBarButtonData & SetMenuItemData

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Hroudtwolf
Addict
Addict
Posts: 803
Joined: Sat Feb 12, 2005 3:35 am
Location: Germany(Hessen)
Contact:

SetToolBarButtonData & SetMenuItemData

Post by Hroudtwolf »

Hi,

I've a little wish again.
To have possibilities for setting and getting of userdefined datas for MenuItems and ToolBarButtons, would be very cool.

An equivalent to SetGadgetItemData/GetGadgetItemData, quasi.

SetToolBarButtonData (#ToolBar, #ButtonID, *Data )
*Data = GetToolBarButtonData (#ToolBar, #ButtonID )


SetMenuItemData (#Menu, #ItemID, *Data )
*Data = GetMenuItemData (#Menu, #ItemID )

In Windows, there wouldn't be any problem to implement this features.
TBBUTTONINFO has a member, called "lParam".
And MENUITEMINFO has a member, called "dwItemData".
Both are predestinated for implementation of such features.
But, I don't now how to do on OS X or Linux.

Best regards

Wolf
User avatar
spikey
Enthusiast
Enthusiast
Posts: 586
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: SetToolBarButtonData & SetMenuItemData

Post by spikey »

+1
Apologies for resurrecting an old post but I was just about to post a feature request when I found this. Now that we have the BindMenuEvent command I think this could be reconsidered.
User avatar
mk-soft
Always Here
Always Here
Posts: 5406
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: SetToolBarButtonData & SetMenuItemData

Post by mk-soft »

I just made it myself.

Since the MenuItemID and ToolBarButtonID must be unique, you don't need the MenuID or ToolBarID. So two maps are enough.

Code: Select all

;-TOP by mk-soft. v1.01.1

Global NewMap ToolBarButtonData.i()
Global NewMap MenuItemData.i()

Procedure GetToolBarButtonData(ToolBarButtonID)
  ProcedureReturn ToolBarButtonData(Str(ToolBarButtonID))
EndProcedure

Procedure SetToolBarButtonData(ToolBarButtonID, Value)
  ToolBarButtonData(Str(ToolBarButtonID)) = Value
EndProcedure
  
Procedure GetMenuItemData(MenuItemID)
  ProcedureReturn MenuItemData(Str(MenuItemID))
EndProcedure

Procedure SetMenuItemData(MenuItemID, Value)
  MenuItemData(Str(MenuItemID)) = Value
EndProcedure

; ****
Last edited by mk-soft on Tue Feb 02, 2021 3:24 pm, edited 1 time in total.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
spikey
Enthusiast
Enthusiast
Posts: 586
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: SetToolBarButtonData & SetMenuItemData

Post by spikey »

mk-soft wrote:I just made it myself.
So did I - that's not the point. I think it could usefully form part of the intrinsic library.
Post Reply