Post Reply 
LibMenu : a simple toolbox for easy menu handling
05-07-2018, 05:55 AM (This post was last modified: 05-07-2018 08:59 AM by tcab.)
Post: #10
RE: LibMenu : a simple toolbox for easy menu handling
Thanks for this library of menu related functions - arguably this should be built into the Prime!

A few questions and tips:
  1. Question: Just wondering what 'LibMenu.deftab' is for and why is it has 'tab' in its name? It seems to create a mutually exclusive set of 'toggle-like' menu buttons, which call functions. My only guess is that the user is expected to build a tabbed UI of some kind and the menu buttons are supposed to indicate which tab in the UI is active - is that right? Since there is no built in Prime tabbed UI - I'm wondering how often this kind of menu button system would get used - as not many users are likely to be building a custom tabbed UI from scratch? Or am I missing something?
  2. Tip: For some reason MSGBOX messages and INPUT forms are not cleared away after being invoked/displayed and completed - which is likely to confuse users. I recommend that these commands should be followed by a RECT() call to clear the screen.
  3. Tip: PRINT() has its issues as previously raised - viz. displaying the terminal ok but not allowing you to scroll, much less see text which has scrolled off the bottom of the terminal. Clearing the terminal first with PRINT() and limiting output to approx 12 lines is a workaround.
  4. Tip: I have had success with TERM the replacement terminal http://www.hpmuseum.org/forum/thread-2667.html, which displays output created by OUT() when you call SHOW() and unlike the built in terminal, lets you actually scroll through the resulting output, and then helpfully, allows you to hit ESC which takes you back to the Lib menu.
  5. Question: With not that many options for displaying results to users - presumably we should also be considering drawing graphic text to the screen?
  6. Tip: It would be nice to be able to exit the menu by pressing the ESC key - here is my technique to do so. Note I check for the ESC key in the main while loop. The 'stay' variable is set to false either by the ESC key or by the 'Exit' menu function.

Code:

local stay, key;

local AA, BB;

EXPORT funct1() BEGIN msgbox("f1"); msgbox("f1 again");  END; // define function that will be called on menu click.
EXPORT funct2() BEGIN INPUT({{A,1}, {B,1},{L0, [6]},{C,{"SI","US"}},{D,{"SIQ","USQ"}},{AA,[2]},{BB,[2]},{M0,[4]}},"Mega input form"); END;
EXPORT funct3() BEGIN rect(); END;
EXPORT funct4() BEGIN local i; for i from 0 to 10 do print("hi there " + i); end; END;
EXPORT funct5() BEGIN local i; for i from 0 to 10 do TERM.OUT("hi there " + i); end; SHOW(); END;

init() begin stay:=true; LibMenu.reset(); end;
exitMenu() begin stay:=false; end; 

EXPORT libmenu_test()
BEGIN
  init(); // resets menu and initialises exit flag
  LibMenu.entry(1,"msg1","funct1()");
  LibMenu.entry(2,"choose","funct2()");
  LibMenu.entry(3,"clear screen","funct3()");
  LibMenu.entry(4,"print","funct4()");
  LibMenu.entry(5,"out","funct5()");
  LibMenu.entry(6,"exit","libmenu_test.exitMenu()");

  LibMenu.draw();
  WHILE stay DO
     LibMenu.events();

    // check for esc
    key := getkey();
    if key = 4 then stay:=false; end;

  END;

  return "all done, thanks"; 
END;
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: LibMenu : a simple toolbox for easy menu handling - tcab - 05-07-2018 05:55 AM



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