command-click on a word

Bob Sneidar bobs at twft.com
Mon Oct 1 18:42:07 EDT 2012


Command clicking and right-clicking are the same thing in OS x (unless you changed the default prefs). What you are really talking about is a contextual menu. These can be modified. I have an app that does it, thanks to someone on this list who showed me how to modify the contextual menu handler built into LC. Be careful though! Get it wrong and it can cause problems in other ways. 

To do this, you have to insert some code into the frontScript. My code, which allows me to right click a field in pointer mode, and select a type of validation from options that I added to the normal contextual menu. If only I could remember the people who help me with this kind of thing and give them credit I would, but my memory is an old man's memory. Always has been. It looks like this:

on revHookBuildObjectEditorContextMenu pMenuTarget, pMenuName, @pMenu, tModifiedMenu
    put the topstack into theCurrentStack
    put the long name of this card of theCurrentStack into theCurrentCard
    put the customkeys of theCurrentStack into theCustomProps
    
    if theCustomProps is empty then
        pass revHookBuildObjectEditorContextMenu
        exit revHookBuildObjectEditorContextMenu
    end if
    
    if word 1 of pMenuTarget is among the items of "field" and \
            ("PreConversions" is among the lines of theCustomProps or \
            "MidValidations" is among the lines of theCustomProps or \
            "PostValidations" is among the lines of theCustomProps) 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-Conversions" 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
    end if
    
    -- preCheck the data type
    if "DataType" is among the lines of the customkeys of pMenuTarget then
        put the DataType of pMenuTarget into theDataType
        if theDataType is not empty then
            put lineoffset(theDataType, pMenu) into theTypeLine
            if theTypeLine is not 0 then
                put "!c" before word 1 of line theTypeLine of pMenu
            end if
        end if
    end if
    
    pass revHookBuildObjectEditorContextMenu
end revHookBuildObjectEditorContextMenu


function dispatchContextMenuPick pMenuName, pWhich
    if "Data Type" is in pWhich or \
            "Validations" is in pWhich or \
            "Conversions" is in pWhich then
        send "initVal" && pWhich to the topstack in 0 seconds
        exit to top -- essential that we do not pass anything along that LC does not expect
    end if
    pass dispatchContextMenuPick
end dispatchContextMenuPick

This code is fairly specific to what I want to do, but if you study it you will be able to discern what it does. The first function intercepts the revHookBuildObjectEditorContextMenu, which is responsible for building the contextual menu for all objects in LC. Having done that, I check for certain conditions, such as a custom property of the stack, and the fact that it was a field that was clicked on. I then proceed to append options to the menu text. The next function conditionally acts upon what was chosen. 
On Oct 1, 2012, at 2:40 PM, Timothy Miller wrote:

> Thanks Peter and Craig,
> 
> Good thoughts, but I wasn't thinking of either one of those things. I am aware of the new LC text property that makes spell check possible in LC, I have looked at the spell-checker in the LC store, and I do remember the HC command-key feature. (Heck, my Atari 64 seems like just yesterday!) You've probably overestimated me. My question was much dumber than that.
> 
> I'm just wondering two things. Is command-clickng on a hilited word an OS thing, or does each application implement this feature independently? If it's an OS thing, it might not be not very hard to implement. In that case why doesn't LC do it? I.e., not just spell-check but all those other cute tricks -- look up on google, look up in the dictionary, cut, copy, etc? 
> 
> Cheers,
> 
> Tim
> 
> 
> On Oct 1, 2012, at 12:28 PM, Peter Haworth wrote:
> 
>> Hi Tim,
>> There was a similar discussion a few months back regarding the spell
>> checking ability built into an OS, specifically OSX.  The outcome of that
>> was simply that LC doesn't provide a way to hook into it so I think the
>> answer to your question would be the same.
>> 
>> There is a third party spell checker application available on the RunRev
>> store but I don;t remember seeing anything for the feature you mentioned.
>> 
>> Pete
>> lcSQL Software <http://www.lcsql.com>
>> 
>> 
>> 
>> On Mon, Oct 1, 2012 at 10:34 AM, Timothy Miller <
>> gandalf at doctortimothymiller.com> wrote:
>> 
>>> I'm not writing to complain about an absent feature. Mostly just curious,
>>> and maybe I'll learn something useful.
>>> 
>>> In recent years, I've come to take it for granted that I can hilite a word
>>> and command-click on it to get a pop-up dialog box with items like "cut"
>>> "copy" "look up in dictionary" and so on. The specific items depend on the
>>> application, but the dialog box usually looks the same.
>>> 
>>> A few minutes ago, I tried this in a text field an a LC stack and thought,
>>> "Hey, why doesn't that work!?" Then I remembered that LC doesn't do that,
>>> as far as I know. Yet I have the impression that this is an OS function
>>> that any application could invoke.
>>> 
>>> So, my question: Is this an OS function? If so, why doesn't LC take
>>> advantage of it?
>>> 
>>> I suppose it could be scripted. Is there an LC add-on that conveniently
>>> adds this functionality? Or maybe there's a simple LC command I don't know
>>> about?
>>> 
>>> Cheers,
>>> 
>>> Tim
>>> _______________________________________________
>>> 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
> 
> 
> _______________________________________________
> 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





More information about the use-livecode mailing list