Imprimir
Publicado el por

Screen tab menus on the HP Prime

The latest HP Prime firmware has introduced several important features, which were lacking in previous releases and that allow to better use the machine resources.

Here we will discuss the drop-down menus and the screen tab menus. This makes communicating with your program much more seamless, GUI-oriented, than the typical question/answer and input field method (that we had to use if we didn’t have access to a Prime SDK (software development kit)

Both need some event-management concepts beforehand. An event is either a key click, or a mouse event. Mouse events can be of several types: click, long click, drag, etc., but we will now concentrate on the simple mouse click, in order to get up and running a short application (this program has been modified from one published by Eddie B. Shore, as many here). We have included some comments so that you can see what’s happening.

We will now focus on the screen tab menus and leave the dropdown menus for tomorrow:

Code:

EXPORT CM(x)

BEGIN

// CAS Custom Menu

// EWS 2014–04–20

LOCAL m,m1,mx,my; //variables containing the mouse event and coordinates

WHILE MOUSE(1)≥0 DO END;

RECT;

TEXTOUT_P(“Choose the function.”,1,1,4);

TEXTOUT_P(“Here you could put a description of the menu functions below”,1,18,4);

TEXTOUT_P(“2: …”,1,35,4);

TEXTOUT_P(“3: …”,1,52,4);

TEXTOUT_P(“4: …”,1,69,4);

TEXTOUT_P(“5: …”,1,86,4);

TEXTOUT_P(“6: …”,1,103,4);

DRAWMENU(“1”,”2”,”3”,”4”,”5”,”6”);

REPEAT

m:=MOUSE;

m1:=m(1);

UNTIL SIZE(m1)>0; //Waiting until the Mouse variable is filled with a mouse event

mx:=m1(1); //Getting the coordinates of such event - first X

my:=m1(2); //Then y

IF my≥220 AND my≤239 THEN //Only if the mouse event in in the lower part of the screen

IF mx≥0 AND mx≤51 THEN

RETURN SUB(x,1,1);

END;

IF mx≥53 AND mx≤104 THEN

RETURN; //your code here;

END;

IF mx≥106 AND mx≤157 THEN

RETURN ; //your code here;

END;

IF mx≥159 AND mx≤210 THEN

RETURN; //your code here;

END;

IF mx≥212 AND mx≤263 THEN

RETURN; //your code here;

END;

IF mx≥265 AND mx≤319 THEN

RETURN; //your code here;

END;

END;

END;

Comentarios: 0
Más sobre: HP prime, programming

Solo los usuarios registrados pueden poner comentarios.
Identificarse y añadir comentario Regístrese ahora