Post Reply 
Softmenu - DrawMenu wrapper
12-05-2014, 10:47 AM (This post was last modified: 12-05-2014 01:04 PM by Angus.)
Post: #1
Softmenu - DrawMenu wrapper
For convenience with my user keyboard I ended up with the Softmenu function. Many might use something similar, but somebody might find the following helpful.
In the example I use the different assignments CR Haeger suggested in the plotting from cas thread to SHIFT+D.

Code:
[/quote]
SoftMenu();

///////////////////////////////////////////////////////////////////////////////////////////
//re-usable soft menu. return 1 through 6 for buttons clicked
///////////////////////////////////////////////////////////////////////////////////////////
SoftMenu(buttons) //buttons is list(6) of strings - names of Softkeys
BEGIN
 DRAWMENU(buttons);          //no typechecking or args checking
 LOCAL inp:=WAIT(-1);
 IF TYPE(inp)!=6 THEN RETURN inp; END; //need list, keystrokes returned
 IF inp(1)!=#0d AND
    inp(1)!=#3d AND
    inp(1)!=#7d THEN RETURN ""; END;
 IF inp(3)<#220d THEN RETURN ""; END; //mouseclicks only on FKeys
 LOCAL btn:=1+IP(inp(2)*6/320);  //calculate button id of x-coordinate
 RETURN btn;
END;


KEY KS_Xttn()
BEGIN
 LOCAL content:={"f(x):=","f->F","F->f",":=","-","-"};
 LOCAL btn:=SoftMenu(content);    

  CASE
    IF btn=1 THEN "f(x):=" END;
    IF btn=2 THEN "Function.F1:=f" END;
    IF btn=3 THEN "f(x):=Function.F1(x)" END;
    IF btn=4 THEN "f(x):="+CAS.Ans END;
    DEFAULT "";    
  END;
END;

Quick and dirty, I know. but I do use this kind a lot. Personally I am happy with the results - if we got some kind of autoexecute for the returned Strings (think about rpn) I would be pleased.

In an other thread I asked if it is possible to distinguish between cas and home: I still could not figure out how that is done.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Softmenu - DrawMenu wrapper - Angus - 12-05-2014 10:47 AM
RE: Softmenu - DrawMenu wrapper - Angus - 12-08-2014, 11:50 AM
RE: Softmenu - DrawMenu wrapper - Snorre - 12-08-2014, 02:22 PM



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