Selecting a field in a List Field

Sarah Reichelt sarahr at genesearch.com.au
Thu Aug 11 20:35:03 EDT 2005


Hi Alexandre,

Welcome to the Revolution!

> I'm a very beginner with Revolution and I want to do the following :
>
>> From a List Field, when I click on a field, another List Field  
>> replaces
>>
> the first one
>
> I want to do something like this
> ----------------------------------
> "Home" List field :
>     1 GoTo menu 1
>     2 GoTo menu 2
>     3 GoTo menu 3
>
> If I click on 'GoTo menu 2' :
> Another List Field replaces the "Home" Field List.
> ----------------------------------
>
> Can someone help me and give me some tips ?
> I tried to compare (on Mouse Down) using SelectedLine() : but I  
> need to
> compare with "line X of item 1"
> How do you replace a FieldList by another ?

Firstly, when clicking in a list field, there are several ways to  
detect which line has been clicked. The two that are probably best  
for you to use are:
the hilitedLine of fld "Home"  -- this gives the line number
the selectedText of fld "Home  -- this gives the text of the clickedLine

You can do this by varying the content of each field:
on mouseUp
   put the selectedText of me into tMenuChoice
   if tMenuChoice = "GoTo menu 1" then
     put "Choice 1" & cr & "Choice 2" & cr & "Choice 3" into me
   else
     -- fill in what happens with the other choices
   end if
end mouseUp

An easier way might be to have the menus in different fields. These  
could appear sequentially depending on which initial choice is  
clicked e.g. Clicking "Goto menu 1" would show a field containing the  
menu 1 options but hide those containing menus 2 & 3 and so on.

on mouseUp
   put the selectedText of me into tMenuChoice
   if tMenuChoice = "GoTo menu 1" then
     hide field "Menu2"
     hide field "Menu3"
     show field "Menu1"
   else
     -- fill in what happens with the other choices
   end if
end mouseUp

HTH,
Sarah





More information about the use-livecode mailing list