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
