Post Reply 
LibMenu : a simple toolbox for easy menu handling
11-11-2016, 06:51 PM (This post was last modified: 09-03-2017 05:47 PM by primer.)
Post: #1
LibMenu : a simple toolbox for easy menu handling
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. it does 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.
EXPORT funct2() BEGIN ... END;

LibMenu.reset() // first, call reset at each new menu
LibMenu.entry(1,"test1","funct1()"); // then you can define each menu entries with entry(position,"caption","function")
LibMenu.entry(2,"test2","funct2()");

LibMenu.draw();// when you want to draw your menu, just call draw method
WHILE 1 DO
 LibMenu.events();  // when you want to rise action call events() method.
END; // that's done !!!

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
BEGIN
// do something
END;
...
LibMenu.entry(1,"test1","myprog.funct1()"); // <== full qualified function name
...

Download v1.1 :

.hpprgm  LibMenu.hpprgm (Size: 3.19 KB / Downloads: 28)

Changelog 1.1 :
fixed : don't multi call function until finger is not released.

===> Jump to version 2.1 * click here * - with a video.

===> Jump to version 3 * click here *


Note : This version 1 is very simple (next versions provide enhanced features)

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


Messages In This Thread
LibMenu : a simple toolbox for easy menu handling - primer - 11-11-2016 06:51 PM



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