Popup Button bug??
Bob Sneidar
bobsneidar at iotecdigital.com
Mon Jan 27 16:18:19 EST 2025
Not at all. I have a File Server Agent that uses socket communications. I first get a list of files from the user, then I query the server or a list of what I call Profiles which right now are just a name and a file path on the server.
I want to present the client user with a list of the names of those profiles. If the user does not select a profile, either by clicking off the menu I pop up, or by hitting the escape key, then I notify the user that they must choose a profile.
If they do choose a profile then I send the server an array with some key/values, and the file data is stored in a numbered array in the data key. Each key in the data keys is first encrypted, then tho whole of the array is arrayEncoded, then base 64Encoded before opening a socket and sending the data.
I tried using the popup menu button but that will not work unless the popup button command is called from a mouseDown or mouseUp handler. I am making the call from a behavior script which is why I was getting the error. And besides, you can’t control the popup menu’s appearance, whereas with a field you can. Also I am anticipating having more values than can be entirely displayed by a popup menu without running out of screen real estate, so a scrolling field works much better.
I’m curious how you would do that with native controls?
Bob S
> On Jan 27, 2025, at 12:27 PM, Craig Newman via use-livecode <use-livecode at lists.runrev.com> wrote:
>
> Bob.
>
> What are you trying to accomplish that the native buttons do not do for you? The popUp command, to me, is simply a tool to invoke a display of resident menuItems that do not necessarily have to live at the button location itself, and that button not even needing to be visible.
>
> Are you adding a lot of additional gadgetry?
>
> Craig
>
>> On Jan 27, 2025, at 2:01 PM, Bob Sneidar via use-livecode <use-livecode at lists.runrev.com> wrote:
>>
>> Interesting, the dictionary didn’t mention mouseUp. But some kind of mouse up or down handler has to be what makes the call.
>>
>> It turns out that rolling your own blocking popup “menu” is not very straightforward. Here is what I came up with:
>>
>> on popupMenu pMenu, pItems, pLocation
>> -- anything less than 3 lines and the scrollbar does not display correctly
>> if the number of lines of pItems >3 and \
>> the last char pItems is cr then \
>> delete last char of pItems
>>
>> set the text of pMenu to pItems
>> set the height of pMenu to \
>> min(the formattedHeight of pMenu, 178) — for me 178 is 10 lines of formattedText YMMV
>> set the width of pMenu to the formattedWidth of pMenu
>> set the topLeft of pMenu to pLocation
>> show pMenu
>> focus on pMenu
>> set the hilitedLine of pMenu to empty -- because focus will auto-select line 1
>> wait until the visible of pMenu is false with messages
>> end popupMenu
>>
>>
>> — in the script of a Scrolling List Field
>> local lParentCard
>>
>> on selectionChanged
>> put getParentCard(the long id of me) into lParentCard
>> put the hilitedLine of me into tLine
>> put line tLine of the text of me into tItem
>> set the currentLocation of lParentCard to tItem — or whatever you want to do with tItem
>> hide me
>> end selectionChanged
>>
>> on escapeKey
>> selectionChanged
>> end escapeKey
>>
>> on focusOut
>> selectionChanged
>> end focusOut
>>
>> FUNCTION getParentCard pObjectID
>> put offset("card id", pObjectID) into tStartChar
>> put char tStartChar to -1 of pObjectID into tCardID
>> return tCardID
>> END getParentCard
>>
>> Bob S
>>
>>> On Jan 27, 2025, at 9:39 AM, Craig Newman via use-livecode <use-livecode at lists.runrev.com> wrote:
>>>
>>> Bob.
>>>
>>> It works just fine in a mouseUp handler as well. I just did it.
>>>
>>> Craig
>>>
>>>> On Jan 27, 2025, at 12:31 PM, Bob Sneidar via use-livecode <use-livecode at lists.runrev.com> wrote:
>>>>
>>>> Understood. That is why I wrote, I assure everyone there *IS* a button called “mnuLocations”. As I posted later, this command can only be used in a mouseDown handler. I think I knew this many, many years ago, but I forgot.
>>>>
>>>> Bob S
>>>>
>>>>
>>>>> On Jan 27, 2025, at 9:28 AM, Craig Newman via use-livecode <use-livecode at lists.runrev.com> wrote:
>>>>>
>>>>> Bob .
>>>>>
>>>>> “popup” is not a command that creates a button. It only works with an existing button, opening its contents at a location of your choice. That button can be hidden, but its menu will appear anyway.
>>>>>
>>>>> Craig
>>>>>
>>>>>> On Jan 27, 2025, at 12:17 PM, Bob Sneidar via use-livecode <use-livecode at lists.runrev.com> wrote:
>>>>>>
>>>>>> Hi all.
>>>>>>
>>>>>> I have the command:
>>>>>> popup pMenuButton at pLocation
>>>>>>
>>>>>> pMenuButton contains:
>>>>>> button “mnuLocations"
>>>>>>
>>>>>> pLocation contains:
>>>>>> 55,303
>>>>>>
>>>>>> I am getting the error:
>>>>>> stack "moduleCardBehavior": execution error at line 360 (subwindow: can't find stack or button), char 1
>>>>>>
>>>>>> I assure everyone there *IS* a button called “mnuLocations”. What in the name of all <fill in the blank> is going on here??
>>>>>>
>>>>>> Bob S
>>>>>>
>>>>>> _______________________________________________
>>>>>> 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
>>>
>>>
>>> _______________________________________________
>>> 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