HP Forums
Efficient Use of Using both GETKEY and Soft Keys - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Efficient Use of Using both GETKEY and Soft Keys (/thread-11192.html)



Efficient Use of Using both GETKEY and Soft Keys - Eddie W. Shore - 08-09-2018 07:59 PM

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.


RE: Efficient Use of Using both GETKEY and Soft Keys - cyrille de brébisson - 08-10-2018 06:26 AM

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


RE: Efficient Use of Using both GETKEY and Soft Keys - Eddie W. Shore - 08-12-2018 01:55 AM

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;



RE: Efficient Use of Using both GETKEY and Soft Keys - Tyann - 08-12-2018 06:12 AM

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.


RE: Efficient Use of Using both GETKEY and Soft Keys - Eddie W. Shore - 08-12-2018 06:42 PM

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;