Use MenuPick properly

dunbarx at aol.com dunbarx at aol.com
Sat Feb 7 12:57:47 EST 2015


Yet another way, just because I like custom properties, is to set a property of the pulldown to your SQL data, and load only the second item of each line on mouseEnter (or some other time). If you want to try a test, make a normal button and a pulldown. In the button script:



on mouseUp
   put "1," & random(999) &  return & "2,b" & return & "3,c" into temp --you would load your SQL data here
   set the tempContents of btn "pullDown" to temp
end mouseUp


In the pullDown:



on mouseEnter
   put the tempContents of me into me
end mouseEnter



Now your menuPick handler can deal with the updated list, and as has been mentioned, the menuhistory can access the proper line from the property.


Craig Newman



-----Original Message-----
From: Peter Haworth <pete at lcsql.com>
To: How to use LiveCode <use-livecode at lists.runrev.com>
Sent: Sat, Feb 7, 2015 12:19 pm
Subject: Re: Use MenuPick properly


Another way to do it that involves more SQL but less Livecode is

set the text of button xyz to revDataFromQuery(,,gDBID,"SELECT <datacolumn>
FROM <tablename> ORDER BY <datacolumn>")

set the cKeys of button xyz to revDataFromQuery(,,gDBID,"SELECT <keycolumn>
FROM <tablename> ORDER BY <datacolumn>")

I think I like that better, simpler and not likely to be be noticeably
slower.

Pete
lcSQL Software <http://www.lcsql.com>
Home of lcStackBrowser <http://www.lcsql.com/lcstackbrowser.html> and
SQLiteAdmin <http://www.lcsql.com/sqliteadmin.html>

On Sat, Feb 7, 2015 at 8:21 AM, Pascal Lehner <tate83 at gmail.com> wrote:

> Hi Pete and Klaus,
>
> thanks for your quick answer!
> Since my items are not in a sequential number I will adapt my code to
> Pete's example.
>
> Have a great weekend!
>
> Pascal
>
>
>
> 2015-02-07 16:47 GMT+01:00 Peter Haworth <pete at lcsql.com>:
>
> > Hi Pascal,
> > After selecting the data from your db, do this
> >
> > command createKeys pdata,pid
> >    --pdata is tab delimited data from revdatafromquery
> >    --   item 1 is the key, item 2 is the display data
> >    --pid is the long id of the menu button
> >
> >    local tKeys,tText
> >
> >    set the itemdelimiter to tab
> >    repeat for each line rLine in pdata
> >       put item 1 of rLine &return after tKeys
> >       put item 2 of rLine & return after tText
> >    end repeat
> >    set the text of pid to tText
> >    set the cKeys of pid to tKeys
> >
> > end createKeys
> >
> > on menuPick pitemname
> >    --use the menuHistory to access the cKeys cprop
> >
> >    put pitemname into field xyx
> >    put line the menuHistory of me of the cKeys of me into field abc
> >
> > end menuPick
> >
> > Pete
> > lcSQL Software
> > On Feb 7, 2015 7:18 AM, "Pascal Lehner" <tate83 at gmail.com> wrote:
> >
> > > Hi all,
> > >
> > > I use menuPick to have a button with a drop down menu. The menu items
> are
> > > loaded from a database and the users selection needs to be stored back
> > > there too.
> > >
> > > the dropdown list looks as following (id, name)
> > > 1, full
> > > 2, half full
> > > 3, empty
> > >
> > > I save the users selection in two fields on the card
> > > item 1 in a hidden field ( to be stored in the database record)
> > > item 2 is displayed in another field
> > >
> > > obviously, the dropdown list does not look very nice like this. Even
> more
> > > so when I look at a real-world example with several words for "name"
> > >
> > > Can you think of a way to display only the "name" in the dropdown list,
> > but
> > > still save the id in the hidden field?
> > >
> > > Thanks,
> > > Pascal
> > > _______________________________________________
> > > 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