Menus, buttons and how to refer to them
Jeanne A. E. DeVoto
jeanne at runrev.com
Tue Dec 31 22:46:01 EST 2002
At 9:22 AM -0800 12/30/02, Graham Samuel wrote:
>>The reason why
> set line 1 of the text of button "Options" of card 1 of this stack to "Blah"
>> doesn't work is that it can't find
>>a property named "line 1 of the text".
>> put "Blah" into line 1 of the text of button \
>> "Options" of card 1 of this stack
>So what that says is that you can't have a qualifier of a property,
>because 'the text of button.." IS a property, despite Björnke von
>Gierke saying that you can't use the 'set' command on text.
Right. This works the same way as in HyperCard or SuperCard: if you set a
property, you need to set all of it - you can't set a chunk of a property.
(In HC, I generally run into this trying to set one line of a script - same
problem, because "script" is a property.)
>a) that qualifiers are forbidden when referring to properties - which
>is easy to remember once you know it.
Not quite: you can't set a particular chunk of a property - you have to set
the whole thing at once - but you can get a chunk of a property. For
example, "put line 3 of button ID 343" works fine.
>b) button contents are properties and also containers like fields,
>which is subtle and not that easy to pick up from the documentation.
Can you tell me where you were looking? (Buttons are listed in "About
Containers, Variables, and Sources of Value", and most of this is explained
there, but I may need to add some notes elsewhere.)
>Now, I know that menus are buttons in Revo and I'm quite happy about
>that, but I am a bit confused about when we use the term 'menu' and
>when we use the term 'button'.
The "menu" term can be used to refer to the menus in the current menu bar.
For example, if the menu bar contains menus "File", "Edit", and "Go", you
can say something like
get menuItem 1 of menu "Edit"
to get the first menu item in that menu.
Because menus are also buttons, you can use button syntax to get the same
information - but you may need to specify the group and stack the button is
in, because if you're referring to it as "button" it can be ambiguous. (For
example, you might have a standard button called "Edit" on the current
card, so simply referring to 'button "Edit"' might give you the button
instead of the menu.) An unambiguous button reference might look like this:
get line 1 of button "Edit" of group "myMenus" of stack "Main"
This will return the same information as the form using "menu", but you
have to know the group name and possibly which stack it's in, so the "menu"
form is a little more convenient for menubar menus.
Jeanne A. E. DeVoto ~ jeanne at runrev.com
Runtime Revolution Limited - The Solution for Software Development
More information about the Use-livecode