Post Reply 
Efficient Use of Using both GETKEY and Soft Keys
08-09-2018, 07:59 PM
Post: #1
Efficient Use of Using both GETKEY and Soft Keys
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.
Visit this user's website Find all posts by this user
Quote this message in a reply
08-10-2018, 06:26 AM
Post: #2
RE: Efficient Use of Using both GETKEY and Soft Keys
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

Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP.
Find all posts by this user
Quote this message in a reply
08-12-2018, 01:55 AM
Post: #3
RE: Efficient Use of Using both GETKEY and Soft Keys
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;
Visit this user's website Find all posts by this user
Quote this message in a reply
08-12-2018, 06:12 AM
Post: #4
RE: Efficient Use of Using both GETKEY and Soft Keys
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.

Sorry for my english
Find all posts by this user
Quote this message in a reply
08-12-2018, 06:42 PM
Post: #5
RE: Efficient Use of Using both GETKEY and Soft Keys
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;
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)