Another Gotcha

Pete pete at mollysrevenge.com
Mon Jan 2 22:22:15 EST 2012


Why not do this in a mouseDown handler for the menu?

On Thu, Dec 29, 2011 at 5:18 PM, Bob Sneidar <bobs at twft.com> wrote:

> S'not. ;-) It's the handler that builds contextual menus. By trapping it
> and doing your own thing you can make your own contextual menus, or add to
> existing ones. I have this in a frontScript which puts a few extra things
> at the top of the contextual menu if a field is the target:
>
> on revHookBuildObjectEditorContextMenu pMenuTarget, pMenuName, @pMenu,
> tModifiedMenu
>    put the topstack into theCurrentStack
>    put the long name of this card of theCurrentStack into theCurrentCard
>    put the customproperties of theCurrentStack into theCustomProps
>    switch
>        case word 1 of pMenuTarget is not "field"
>            put "false" into valOn
>            break
>        case not theCustomProps is an array
>            put "false" into valOn
>            break
>        case "PreValidations" is among the keys of theCustomProps
>            put "true" into valOn
>            break
>        case "MidValidations" is among the keys of theCustomProps
>            put "true" into valOn
>            break
>        case "PostValidations" is among the keys of theCustomProps
>            put "true" into valOn
>            break
>    end switch
>
>    if valOn then
>        put "Data Type" into line 1 of theValMenu
>        put tab & "Text" into line 2 of theValMenu
>        put tab & "Number" into line 3 of theValMenu
>        put tab & "Date" into line 4 of theValMenu
>        put "-" into line 5 of theValMenu
>        put "Pre-Validations" into line 6 of theValMenu
>        put "Mid-Validations" into line 7 of theValMenu
>        put "Post-Validations" & lf & "-" & lf into line 8 of theValMenu
>        -- put the valMenu of me into theValMenu
>        put theValMenu before pMenu
>        put pMenu
>    end if
>    pass revHookBuildObjectEditorContextMenu
> end revHookBuildObjectEditorContextMenu
>
>
> function dispatchContextMenuPick pMenuName, pWhich
>    if "Data Type" is in pWhich or "Validations" is in pWhich then
>        send "initVal" && pWhich to the topstack in 0 seconds
>        exit to top
>    end if
>    pass dispatchContextMenuPick
> end dispatchContextMenuPick
>
>
> On Dec 29, 2011, at 4:04 PM, Richard Gaskin wrote:
>
> > Bob Sneidar wrote:
> >
> >> I have been using a trick John Craig showed me for appending to a
> contextual menu which has been very handy for me. The gotcha is that
> instead of building the menu on the fly using "put theMenuItem into line 1
> of theMenu" (or something like that) I decided to simply create a custom
> property with the additional menu items I wanted, and then put that
> property before pMenu in the revHookBuildObjectEditorContextMenu handler in
> my front script.
> >
> > "revHookBuildObjectEditorContextMenu"?
> >
> > Where is that documented?
> >
> > --
> > Richard Gaskin
> > Fourth World
> > LiveCode training and consulting: http://www.fourthworld.com
> > Webzine for LiveCode developers: http://www.LiveCodeJournal.com
> > LiveCode Journal blog: http://LiveCodejournal.com/blog.irv
> >
> > _______________________________________________
> > use-livecode mailing list
> > use-livecode at lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>


-- 
Pete
Molly's Revenge <http://www.mollysrevenge.com>



More information about the use-livecode mailing list