The Museum of HP Calculators

HP Forum Archive 21

[ Return to Index | Top of Index ]

HP Prime DRAWMENU
Message #1 Posted by Mic on 20 Oct 2013, 11:59 a.m.

Hello,

Somebody knows how to detect a click on a menu drawn with DRAWMENU command on HP Prime ?

      
Re: HP Prime DRAWMENU
Message #2 Posted by Wes Loewer on 20 Oct 2013, 5:01 p.m.,
in response to message #1 by Mic

Quote:
Somebody knows how to detect a click on a menu drawn with DRAWMENU command on HP Prime ?

Here's what I used:

  m := MOUSE;
  m1 := m(1);
  mx := m1(1);
  my := m1(2);
  menu := softmenu(mx,my,n);

where softmenu() is defined to be

////////////////////////////////////////////////////////////
// converts pixel x,y into a menu choice
// returns menu number (1 through n)
// returns 0 if an invalid menu option was selected (>n) or tap was exactly between two menu options
// returns -1 if y was not in softmenu region of the screen
softmenu(x,y,n)
BEGIN
  LOCAL m;

m:=-1; IF y >= 220 THEN CASE IF 0 <= x <= 51 THEN m := 1; END; IF 53 <= x <= 104 THEN m := 2; END; IF 106 <= x <= 157 THEN m := 3; END; IF 159 <= x <= 210 THEN m := 4; END; IF 212 <= x <= 263 THEN m := 5; END; IF 265 <= x <= 319 THEN m := 6; END; DEFAULT m:=0; // if it's right in between menu options END; // check to see if valid menu option was selected IF m > n THEN m := 0; END; END; RETURN m; END;

-wes

            
Re: HP Prime DRAWMENU
Message #3 Posted by Mic on 21 Oct 2013, 3:23 a.m.,
in response to message #2 by Wes Loewer

Thank you, I used this way with coordonates detection. I thought there was a specific command for the drawn menus.

            
Re: HP Prime DRAWMENU
Message #4 Posted by John Colvin on 24 Oct 2013, 12:47 a.m.,
in response to message #2 by Wes Loewer

The list returned from a MOUSE call contains the x and y values in the following format #nnn:16d For example if I touch the menu key 6, I get #273:16d as the x pixel coordinate. How can I extract the value 273 - the x value from this expression? I can't use the list format of the x,y coordinates in a conditional statement.

                  
Re: HP Prime DRAWMENU
Message #5 Posted by Joe Horn on 25 Oct 2013, 6:11 a.m.,
in response to message #4 by John Colvin

Quote:
The list returned from a MOUSE call contains the x and y values in the following format #nnn:16d For example if I touch the menu key 6, I get #273:16d as the x pixel coordinate. How can I extract the value 273 - the x value from this expression? I can't use the list format of the x,y coordinates in a conditional statement.
The B->R function converts these 16-bit integers to reals, but you don't have to; you can use comparisons without converting them. You can also use the SUB command (or subscript notation) to extract individual items from that list, of course. Hope that helps!


[ Return to Index | Top of Index ]

Go back to the main exhibit hall