Adding an 'Edit Behavior' item to the IDE context menu
Posted: Wed Jan 01, 2014 2:11 pm
Happy new year, everyone. The MobGUI plugin has an optional menu item in the IDE context menu to edit the behavior of a control (or controls) and it was pointed out that this would be a handy thing to have in general, so here it is.
Hopefully this little feature will make it's way into LiveCode's IDE, but - in the meantime - you can always add this snippet to your own utilities, or even just use it as is.
... and here it is in a little plugin ...
Enjoy the rest of the holiday period!

Code: Select all
# catch the IDE's context menu message
on revHookBuildObjectEditorContextMenu pMenuTarget, pMenuName, @pMenu, pModifiedMenu
local tMenu, tSelected, tBehavior
# custom menu item
repeat for each line tSelected in selObj()
put the behavior of tSelected into tBehavior
if tBehavior <> empty and exists(tBehavior) then
put "Edit Behavior" & LF after tMenu
exit repeat
end if
end repeat
# prepend the standard context menu
if tMenu <> empty then
put tMenu & "-" & LF before pMenu
end if
pass revHookBuildObjectEditorContextMenu
end revHookBuildObjectEditorContextMenu
# catch the IDE's message when an item is selected from the context menu
function dispatchContextMenuPick pMenuName, pItem
local tSelected, tBehavior
switch word 1 to -1 of pItem
case "Edit Behavior"
repeat for each line tSelected in selObj()
put the behavior of tSelected into tBehavior
if tBehavior <> empty and exists(tBehavior) then
edit the script of tBehavior
end if
end repeat
exit to top
break
end switch
pass dispatchContextMenuPick
end dispatchContextMenuPick
Enjoy the rest of the holiday period!