Page 1 of 1

Active field when opening card?

Posted: Mon Nov 13, 2006 11:37 pm
by dwolff
Hi all,

I'm converting many stacks from HyperCard to Revolution. Several of these have many fields, like address book stacks. One problem I have not yet gotten past: When a card opens, one of the fields is selected (active). So, among other problems, if I accidentally type something, the field text is destroyed.

How can I turn off this auto-select behavior? Where is it set?

Thanks --

David

Re: Active field when opening card?

Posted: Tue Nov 14, 2006 12:35 am
by marielle
dwolff wrote:So, among other problems, if I accidentally type something, the field text is destroyed.
Check out these in the dictionary

focus
Use the focus command to make a control active--that is, to make it receive any keystrokes the user types.

(obviously, you will choose to set the focus on a control *other* than the field... for instance an "ok" button or some non editable nterface element)

traversalOn
Setting a field's traversalOn to true enables the user to tab into or click in the field for editing (if the field's lockText property is false). If a field's traversalOn and lockText properties are both set to true, the user can select text, but not change it, and can scroll within the field using the keyboard. If the traversalOn is true and the lockText is false, the field can be edited. If the lockText is true and the traversalOn is false, the user can neither select nor edit the field's text.

Posted: Tue Nov 14, 2006 6:26 am
by dwolff
Thanks, I've read each of those umpty-twelve times. :cry:

Does Revolution automatically set the focus to one of the group fields? Can I turn off that behavior other than by setting the focus elsewhere, on every OpenCard?

Thanks --

David
[/quote]

Posted: Tue Nov 14, 2006 10:30 am
by Mark
Assuming that Revolution always focuses on field 2 while you want field 1 to be focuses on openCard, the following script does the job:


on preOpenCard
repeat with x = 1 to number of fields
set the traversalOn of fld x to false
end repeat
end preOpenCard

on openCard
repeat with x = 1 to number of fields
set the traversalOn of fld x to true
end repeat
focus on fld 2
end openCard

Best,

Mark

Posted: Wed Nov 15, 2006 12:19 pm
by Garrett
Yes, you can use the "on opencard" in the card's script and focus on any
object you wont, of course avoiding the objects you don't want focused
on.

In the documentation, scroll down to "focus".
Summary:
Places the insertion point in a field or makes a control active.

Examples:
focus on field "Label"
focus on the mouseControl
focus on graphic "Move Me"
I imagine though that you'll need another object that has the ability to be
focused on in order to take the focus away from any object you don't
want the focus on.

-Garrett

Posted: Wed Nov 15, 2006 12:34 pm
by Mark
Hi Garrett,

First of all, you don't need another object. However, even if you had another object to take the focus away, as you call it, opening the card would automatically re-focus the first field. That is why I turn off the traversalOn of all fields on preOpenCard and turn then on again on openCard, in my example. There may be a simpler way, but at least I know that this method never never fails.

Best,

Mark

Posted: Thu Nov 16, 2006 9:52 pm
by Garrett
Wow, that's a bummer. I didn't know that happens. :-(

-Garrett

Re: Active field when opening card?

Posted: Wed Nov 22, 2006 3:58 am
by dwolff
marielle wrote:
dwolff wrote:So, among other problems, if I accidentally type something, the field text is destroyed.
Check out these in the dictionary

<snippage>

traversalOn
Setting a field's traversalOn to true enables the user to tab into or click in the field for editing (if the field's lockText property is false). If a field's traversalOn and lockText properties are both set to true, the user can select text, but not change it, and can scroll within the field using the keyboard. If the traversalOn is true and the lockText is false, the field can be edited. If the lockText is true and the traversalOn is false, the user can neither select nor edit the field's text.
So. Revolution always focuses on a traversable field on every OpenCard, yes? (This is not documented that I can find. It's also different from HyperCard behavior, so it's snagged me.)

Is there anywhere a list of what messages are sent during various events such as opening a card?

Now I'm looking for a simple way to lock things. Just checked the "cantmodify of this stack" and apparently that does not prevent editing fields!

Thanks --

David

Posted: Sat Dec 16, 2006 3:33 am
by dwolff
Garrett wrote:Yes, you can use the "on opencard" in the card's script and focus on any
object you wont, of course avoiding the objects you don't want focused
on.

In the documentation, scroll down to "focus".
Summary:
Places the insertion point in a field or makes a control active.

Examples:
focus on field "Label"
focus on the mouseControl
focus on graphic "Move Me"
I imagine though that you'll need another object that has the ability to be
focused on in order to take the focus away from any object you don't
want the focus on.

-Garrett
I decided to take this course. (BTW, I couldn't find any documentation that matches your quote... where is that?)

The stack script now has this handler:

Code: Select all

On OpenCard
  Focus on bg field "EatRevFocusKludge"
  Pass OpenCard
End OpenCard
and there is an appropriate bg field.

The idea of un-setting and re-setting a property for every field on the card (possibly 10-20!) on every card open seemed... non-optimal.

It doesn't seem to want to focus on a button, as was suggested above, only a (traversable and enabled) field. Which however can be hidden behind another field. This has the disadvantage of eating left-arrow and right-arrow keys but I could add a script to the field to deal with this.

Again, is there a list of all messages sent by various actions?

Thanks --

David

Posted: Sat Dec 16, 2006 3:53 am
by Mark
Again, is there a list of all messages sent by various actions?
No. There are the functions commandnames and functionnames, but there is no messagenames. So, there is no list of actions and related messages and there isn't even a list of messages. However, you can enter "message" as a query in the docs and you will get a list of all messages.

I don't think it is doable to compile an exhaustive list of all possible user actions and all invoked messages, such as: open a card, closeCard, openCard, preOpencard, possibly preOpenStack and openStack, etc etc etc.

Best,

Mark

Posted: Fri Dec 22, 2006 4:58 am
by dwolff
Mark wrote:
Again, is there a list of all messages sent by various actions?
<snippage>
I don't think it is doable to compile an exhaustive list of all possible user actions and all invoked messages, such as: open a card, closeCard, openCard, preOpencard, possibly preOpenStack and openStack, etc etc etc.
I must be really unclear.

Is there a list of the messages that Revolution automatically sends on various events, for example when going to a different card?

For example, in HyperCard, somewhere I have a list of what HyperCard sends when I delete a card (closeCard, deleteCard, then openCard; possibly with some xxxBackground messages if it was the last card in the background).

A book, maybe?

Thanks --

David

Posted: Fri Dec 22, 2006 7:11 am
by Mark
Hi David,

I think you cut out the wrong part of the quote. As I wrote in me previous message:

...you can enter "message" as a query in the docs and you will get a list of all messages.

As far as I know, this is the only practicle way to get a list of messages.

Best,

Mark

Posted: Fri Dec 22, 2006 4:09 pm
by FourthWorld
Mark wrote:
Again, is there a list of all messages sent by various actions?
I don't think it is doable to compile an exhaustive list of all possible user actions and all invoked messages, such as: open a card, closeCard, openCard, preOpencard, possibly preOpenStack and openStack, etc etc etc.
And of it were it'd be too tedious to read. :)

It may be more helpful to examine messages interactively with the Message Watcher.