Quote:t appears that @GetFromKeyboard() only works in Text elements. And @GetFromKeyboard() only traps alpha-numberic keys, does not capture any function keys. Trying to use Up/Down arrows for example do not seem to get trapped, probably because they have no ascii value.
It does not need to be from a text element. I just used it On Form Enter without problem. It can be used from any element on a form in any event after the form has been opened. It traps events from the main Sesame window - not any particular element in that window.
It also traps all keys, not just those with ASCII equivalents - that is why it returns an integer rather than a byte. The value of the Up Arrow key on most keyboards will be 65362. You
must use integers unconverted to characters to use this function.
Quote: I wanted to trigger actions by entering "?" in a field, and it only works in Text. Entering into Number, Money, Date, Time elements generates an error about wrong type or just passes the character along.
And even in the Text element, the "?" is passed on to the element (with and without using GiveToKeyboard). This was a simple sample test to add a string to the existing value:
What are you using to trigger the event to run in the first place? If, for example you are using on LE enter - then your code will run once, complete and not run again until the LE is re-entered. That will produce exactly the symptom you are noting. If you put it in LE immediate change, it will only run
after the first keystroke has changed the LE, then it will run once, and without a loop - stop, until the next change.
Quote: I was expecting @GetFromKeyboard would eliminate the keystroke from being passed along until GiveToKeyboard() was generated. I had to use @Replace to remove the "?" that I thought would be stripped out.
It needs to be put in a loop to act as a filter.
Quote: Some questions:
1. Why does @GetFromKeyboard still get passed on to the element?
2. What does GiveToKeyboard do?
3. When should it be used? I am putting test code in event for ImmediateChange.
4. If I am correct that theses functions only work with Text Fields, could it please be changed in the future to also work in Numbers/Money/Date/Time fields?
5. Could it also be expanded to trap the keyvalue from the keyboard vs. using the ascii value?
1. It doesn't. If placed in LE enter, it will trap (and dispose of) the first keystroke entered. To prevent further keys from being placed in the LE, a loop is required.
2. It puts the last trapped keystroke back in the event queue.
3. It pretty much cannot be used in immediate change in that it will not run until the user does hit a key and changes the LE. Instead put it in LE enter, or Form enter, and use a loop with an exit condition.
4. It will work in any LE type that has programmable events.
5. It traps all keystrokes and they are returned as integers. This can be demonstrated by placing the following in the On Enter event of any LE:
var aa as int
var cnt as int
cnt = 0
while(cnt < 10)
{
aa = @GetFromKeyboard()
writeln(aa)
cnt = cnt + 1
}