HP Forums

Full Version: Efficient Use of Using both GETKEY and Soft Keys
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is there an efficient way to use both GETKEY and DRAWMENU in a program? I recurved a request that wants me to recreate a program in the style of the HP 48 (particularly FIF) on the Prime, but just like the 48.

Any help would be appreciated. Thanks.
Hello,

DrawMenu will probably need to be used in conjunction with Wait and Mouse...

wait(-1) will return after either 60seconds, OR a key or a mouse event. It will also be waiting in low power mode, thus saving power.

See wait help for more info.

Cyrille
The following code works well for consecutive key presses, but it errors out after the first mouse click:
Code:

TEST5793()
BEGIN
LOCAL K;
REPEAT
K:=WAIT(-1);
PRINT(K);
UNTIL SIZE(K)==1 AND K==4;
END;
Bonjour

WAIT(-1) renvoie une liste si vous touchez l'écran et une valeur numérique
si vous appuyez sur une touche.
Pour éviter de déclencher une erreur il faut faire un test avec TYPE avant de traiter les
réponses.


Hello

WAIT (-1) returns a list if you touch the screen and a numeric value
if you press a key.
To avoid triggering an error, you must do a test with TYPE before processing
answers.
Tyann, thank you so much, the program works a lot better!

Here is a new revised TEST5793. Key clicks return getkey numbers, mouse clicks return x and y pixel information. Only clicks are accepted, drags and holds are not acknowledged.
Code:

EXPORT TEST5793()
BEGIN
LOCAL K,T;
REPEAT

// get input and type
K:=WAIT(-1);
T:=TYPE(K);

// if input is a key (real number)
IF T==0 THEN
PRINT(K);
END;

// if input is a click (touch)
// type 6 is a list
IF T==6 AND K(1)==3 THEN
// we want clicks only (wait event 3)
// on event 3, {3, x, y}
PRINT(B→R(K(2))+" , "+B→R(K(3)));
CONTINUE;
END;


UNTIL T==0 AND K==4; // ESC key
END;
Reference URL's