LibMenu : a simple toolbox for easy menu handling +- HP Forums (http://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: HP Prime Software Library (/forum-15.html) +--- Thread: LibMenu : a simple toolbox for easy menu handling (/thread-7220.html) |
LibMenu : a simple toolbox for easy menu handling - primer - 11-11-2016 12:51 PM Hi, Here is a small Lib I made to handle menu in a simple way. If you needed to use DRAWMENU(), you know that you have to handle yourself MOUSE events to trigger actions, this lib cover the whole process. API : - LibMenu.reset() : prepare for a (new) menu, call it first. - LibMenu.entry(pos, label, action) : register a menu entry, at given position (1 to 6). action is a string with function name that will be triggered. - LibMenu.draw() : draw the menu (like the buildin DRAWMENU) - LibMenu.events() : check if user has clicked on a menu entry and trigger actions. do not stop program execution, to be used in your program loop. How to use : Code: EXPORT funct1() BEGIN ... END; // define function that will be called on menu click. Obviously, you had to define your own actions in func1() and funct2() functions. Important : if your functions are not public (no EXPORT), you have to provide the full qualified name (with your program name), like this : Code: funct1() //without EXPORT Changelog 1.1 : fixed : don't multi call function until finger is not released. Version 2.1 : Changelog : - added a new entry type : toggle button. - can now display up to 10 menu entries (on two screens, automatically set "next"/"prev") Added API : - LibMenu.entrytoggle(pos,label) : add entry <pos> as a toggle button. - LibMenu.gettoggle(pos) : return toggle status for entry number <pos>. Demonstration : video Version 3 : Changelog : - added a new entry type : tab button. - can now change toggle flag - removed EXPORT from methods, you must prefix method with LibMenu. Added API : - LibMenu.deftab(pos1,pos2,active) : each entries are now tab entries. (from pos1 to pos2) - LibMenu.chgflag(pos) : change toggle flag. Tab usage example : Code: LibMenu.entry(1,"tab1","tstLibM.f1()"); // define action : f1() |