Post Reply 
DRAWMENU function.
02-07-2014, 11:10 AM
Post: #1
DRAWMENU function.
How can the menu buttons be used once DRAWMENU has assigned a string to them?

Can one call a program by pecking a menu button?

Can one assign some action to a button?

Thanks in advance for any help.

Happy coding and may you see ' i No errors in the program ' with every compilation.
Find all posts by this user
Quote this message in a reply
02-09-2014, 02:49 PM
Post: #2
RE: DRAWMENU function.
Here is on old thread about finding out about the menu key selected by the user. It's essentially a matter of interpreting the result of MOUSE().

Marcus von Cube
Wehrheim, Germany
http://www.mvcsys.de
http://wp34s.sf.net
http://mvcsys.de/doc/basic-compare.html
Find all posts by this user
Quote this message in a reply
02-09-2014, 06:31 PM
Post: #3
RE: DRAWMENU function.
I hope that the future firmware add the ability to use soft menu outside a program as user-key to launch build-in or user function and program...
Quote this message in a reply
02-11-2014, 07:14 AM
Post: #4
RE: DRAWMENU function.
Hello,
i was just trying to write some code around the MOUSE and DRAWMENU commands but i have an errore i don't find. it seems my code is not able to cope with the menu area.

the code is based on Les and Cirille codes. Why I am not able to detect the menu X position in order to understand which menu was pushed/clicked?
Code:

 EXPORT Prova_mn()
 BEGIN
  while 1 do
   RECT();
   DRAWMENU("uno","due","tre","quatro","cinco","SEI");
   local l:=WAIT(-1), m; // wait for a user input
   IF TYPE(l)=6 and l(1)=#0 THEN // verify that we have a list corresponding to a mouse down...
    local mx:=B→R(l(2)), my:=B→R(l(3)); // x and y for the click zone
    if my>220 then // in the menu zone
     CASE
      IF   0 <= mx <=  51 THEN m:= 1;  END;
      IF  53 <= mx <= 104 THEN m:= 2; END;
      IF 106 <= mx <= 157 THEN m:= 3; END;
      IF 159 <= mx <= 210 THEN m:= 4; END;
      IF 212 <= mx <= 263 THEN m:= 5; END;
      IF 265 <= mx <= 319 THEN m:= 6; END;
      DEFAULT m:=-2; // if it's right in between menu options
     END; // end_of_case
    END;  // end_of_if_my>220
    RETURN m;
   END;
 // end_of_if_type
  END; 
// end_of_while
 END;  // end_of everything
Thanks

Giancarlo
Find all posts by this user
Quote this message in a reply
02-11-2014, 02:50 PM (This post was last modified: 02-11-2014 06:40 PM by Damien.)
Post: #5
RE: DRAWMENU function.
Hi, Giancarlo

This code based on yours should work:
Code:

EXPORT Prova_mn()
 BEGIN
 RECT_P();
 DRAWMENU("uno","due","tre","quatro","cinco","SEI");
 local mx,my,m,l;
 WHILE 1 do
  l:=WAIT(-1);// wait for a user input
  IF TYPE(l)==6 THEN // verify that we have a list corresponding to a mouse down...
   IF l(1)>0 THEN // is the list empty or not
    mx:=B→R(l(2));my:=B→R(l(3)); // x and y for the click zone
     IF my>220 then // in the menu zone
     CASE
      IF   0 <= mx <=  51 THEN m:= 1; END;
      IF  53 <= mx <= 104 THEN m:= 2; END;
      IF 106 <= mx <= 157 THEN m:= 3; END;
      IF 159 <= mx <= 210 THEN m:= 4; END;
      IF 212 <= mx <= 263 THEN m:= 5; END;
      IF 265 <= mx <= 319 THEN m:= 6; END;
      DEFAULT m:=-2; // if it's right in between menu options
     END; // end_of_case
    END;  // end_of_if_my>220
    RETURN m;
   END;
  END;
 // end_of_if_type
 END; 
// end_of_while
END;  // end_of everything

Regards.

Damien.
Find all posts by this user
Quote this message in a reply
02-11-2014, 06:17 PM
Post: #6
RE: DRAWMENU function.
(02-11-2014 07:14 AM)Giancarlo Wrote:  
Code:

   local l:=WAIT(-1), m; // wait for a user input
   IF TYPE(l)=6 and l(1)=#0 THEN // verify that we have a list corresponding to a

Here is where you are guaranteed to run into issues. You cannot use an AND statement because the local variable l may OR MAY NOT be a list. If the WAIT(-1) command returns a mouse event, l is a list, and the AND statement works. But if WAIT(-1) times out or is returns a keyboard even, then l is a numeric value (not a list) and l(1) produces an error.

Separate your code into two blocks: one that handles mouse events and the other to handle keyboard events. I recommend:

Code:

  local l:=WAIT(-1);
  IF TYPE(l)==6 THEN doMouseEvent(); ELSE doKeyboardEvent(); END;

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
02-11-2014, 08:40 PM
Post: #7
RE: DRAWMENU function.
Thanks guys; it works,

bye

Giancarlo
Find all posts by this user
Quote this message in a reply
Post Reply 




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