[Closed] Toolbar ICustButton inconsistent state
Hi.
I have a nicely working macro checkbutton that I programmatically added to slate editor toolbar.
But when I click it other toolbars don’t update their button states and vice versa. When I click it on other toolbar slate toolbar button stays in unchanged state.
Any ideas?
So something like Ribbon button, not updating on RMC opening or closing Ribbon toolbar…
what is the order on the picture (top to bottom)?
main toolbar, custom toolbar, slate editor toolbar. right?
did you try to add the button to slate editor toolbar manually? does it behave the same way?
Yes, the order is correct.
I couldn’t find a way to add it manually, slate doesn’t allow to customize its toolbar.
I did compare ICustButton from main toolbar with the one in slate, and it seems that the first uses ActionItem to call the macro.
But when I make my button that uses exactly the same ActionItem it suddenly becomes a PushButton. I’ve checked everything but without a result.
g = (dotNetClass "Autodesk.Max.GlobalInterface").Instance
ICustToolbar.DeleteItemByID 66666 -- trying to delete previously created button
CENTER_TOOL_VERTICALLY= 0xffffffff
WS_CHILD = 0x40000000
WS_VISIBLE = 0x10000000
style = bit.or WS_CHILD WS_VISIBLE
btn = g.ToolOtherItem.Create "CUSTBUTTONWINDOWCLASS" 24 24 66666 (dotNetObject "System.UIntPtr" style) CENTER_TOOL_VERTICALLY "" 0 31
btn.Type = btn.Type.Checkbutton
ICustToolbar.AddTool btn ICustToolbar.NumItems
ICustButton = ICustToolbar.GetICustButton 66666
-- mbdata = g.macrobuttondata.create macro_id "macrolabel" "macroTip" 0 "someIcon" -- #1 default constructor
mbdata = g.macrobuttondata.create 647394 macro_id "label" "tip" 0 "iconBmpName" -- #2 mbData as ActionItem
ICustButton.MacroButtonData = mbdata
macro_icon = g.MaxBmpFileIcon.create "iconBmpName" 1
macro_icon2 = g.MaxBmpFileIcon.create "iconBmpName" 1
/*
-- this is how max main toolbar macro checkbutton MacroButtonData setup looks like
-- using this settings makes my button a PushButton :(
actionTable = g.coreinterface.ActionManager.GetTable 82
actionItem = actionTable.GetAction macro_id
mbdata.ActionItem_ = actionItem
mbdata.TblID_ = actionTable.Id_
mbdata.CmdID_ = macro_id
mbdata.MacroScriptID = 0
mbdata.MacroType = 3
mbdata.Flags = 1
*/
ICustButton.SetIcon macro_icon 16 16
ICustButton.SetInIcon macro_icon2 16 16
ICustButton.SetButtonDownNotify true
g.releaseICustButton ICustButton
and a much shorter version of the above code
t.DeleteItemByID 66666
mbdata = g.macrobuttondata.create 647394 27584 "label" "tip" 0 "cutIcon"
b = g.toolmacroitem.create 24 24 mbdata 31
b.type = b.type.checkbutton
b.id = 66666
t.AddTool b t.NumItems
cb = t.GetICustButton 66666
cb.SetType (dotNetClass "Autodesk.Max.CustButType").Check
g.releaseICustButton cb
hi, i managed to make some buttons, however i can’t set the id of the icustbutton no matter what, and so i can’t use any mewthod on it (neither delete or get)
is it something broken in 2020?
thanks
That’s exactly what we used to add buttons to sme. No complains from users of 2020 so far
if not ButtonExists toolbar_hwnd btnText then
(
local mbdata = gi.macrobuttondata.create macro_settings_ID "" "DropToSlate Settings" 0 "DropToSlate"
local toolMacroItem = gi.toolmacroitem.create 24 24 mbdata 31
toolbar.AddTool toolMacroItem toolbar.NumItems
local items = windows.getChildrenHWND toolbar_hwnd
UIAccessor.SetWindowText (items[items.count])[1] btnText
)
my problem is the icustbutton id which i can’t set so i can’t use the GetICustButton(int id) because id is always 0.
I think all macro buttons have ID equal to zero. It’s those buttons that have ActionItem associated with them have the corresponding IDs.
And also macro buttons don’t emit WM_COMMAND with associated ID