Popup menu & menuhistory

Marty Knapp martyknapp at comcast.net
Fri Apr 22 12:44:22 EDT 2011


Thanks for the suggestion Craig. I did tinker with this some more:

So in my test field I have this script:

on mousedown whichButton
    if whichButton is not 3 then exit mousedown
    put the mouseLoc into ML
    get lineOffset(the text of me,btn "myPopUpButton")
    if it is not 0 then
       --For the X coordinate: move the menu over to the left a bit so 
it's under the cursor
       subtract 8 from item 1 of ML

       --For the Y coordinate: take the line number and multiply by 
apparent line
       --height of menu text and adjust so the menu pops up at the 
correct line
       subtract (it*19)-10 from item 2 of ML
    end if
    popup btn "myPopUpButton" at ML
end mousedown


Then in my hidden test popup menu, I have numbers 1 through 35. This 
works until I type in a number that causes the popup menu to hit the top 
of the screen. Unlike an option menu, it does not truncate itself with a 
scroll arrow - it just stops at the top of the screen with the first 
menu item at the top. Interesting, it will truncate with a scroll arrow 
if it hits the bottom of the screen.

Any thoughts or suggestions?

Thanks,
Marty Knapp
> It seems like there should be an easy way to do this, but I cannot find it. I made an ugly workaround with a two buttons. I'm sure you can modify it to make your data entry field do the same thing. With a popup button ("yourPopUpButton") and an action button, try this in the action button script:
>
>
>
> on mousedown
>     popup btn "yourPopUpButton"
> end mousedown
>
>
> on mouseup
>        set the screenmouseLoc to (item 1 of the loc of me + 125&  ","&  item 1 of the loc of me + 195)
> end mouseup
>
>
>
> Note that the screenMouseLoc is a property, whereas the mouseLoc is a function. You will have to modify this in your own stack to account for relative placement of the objects in question. Play around with the coordinates.
>
>
> I don't know why there isn't a property for this in local window terms, as opposed to a function. I hear that setting the loc of the cursor is considered dicey in UI terms.
>
>
> Anyway, if you set the numbers up correctly, you can see that when clicking on the action button, a menuItem from the popup will be selected.
>
>
> Now for the weird stuff. THE MOUSE NEED NOT BE RELEASED for this to work.  The mouseUp message should never be sent. So how do it know?  If the mouseUp handler is commented out, the location of the cursor is not set, Jacques, I need an aspirin.
>
>
> Anyone? This baffles me, even though it works fine.
>
>
> Craig Newman
>
>
>
>
> -----Original Message-----
> From: Marty Knapp<martyknapp at comcast.net>
> To: How to use LiveCode<use-livecode at lists.runrev.com>
> Sent: Thu, Apr 21, 2011 12:19 am
> Subject: Popup menu&  menuhistory
>
>
> I have a field that I've configured to display a popup menu using a hidden popup menu button. If a user starts to type into this field, I use a type-ahead routine that grabs its guess from the menu items in the button. Is there a way to set this up so that if they type something, then click for the popup menu, for the menu to pop up at the line where this text is found (like in an option menu)? Setting the menuhistory doesn't seem to work.
>
> Thanks for any help,
> Marty Knapp




More information about the use-livecode mailing list