Page 1 of 1

SetToolBarButtonData & SetMenuItemData

Posted: Sun Oct 19, 2008 7:24 am
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

Re: SetToolBarButtonData & SetMenuItemData

Posted: Tue Feb 02, 2021 2:34 pm
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.

Re: SetToolBarButtonData & SetMenuItemData

Posted: Tue Feb 02, 2021 3:21 pm
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

; ****

Re: SetToolBarButtonData & SetMenuItemData

Posted: Tue Feb 02, 2021 3:23 pm
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.