How Drawmenu work's? - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: HP Prime (/forum-5.html) +--- Thread: How Drawmenu work's? (/thread-7163.html) |
How Drawmenu work's? - fabio.hdl - 11-03-2016 05:02 PM First of all Hello to everybody, i'm new in this forum! If i'm posting this in the wrong place, since here is my apology. Well, i'm having some trouble with HP PPL, more especifically with DRAWMENU command, i want to know how i handle with it, I managed to draw the menu but i don't know how to interact with it. My question is, do the HP PPL have a command to menu events? Like ISKEYDOWN();? Or i'll have to make a MOUSE event to know the coordenate of the menu? Again, i'm sorry if this question has already been answered, like i said i'm new here! RE: How Drawmenu work's? - Han - 11-03-2016 06:41 PM It's only a drawing routine. You would have to build your own key handler and interface. Old and extremely simple example: http://www.hpmuseum.org/forum/thread-315.html Just look at the main loop for an example of how to trap screen touches. RE: How Drawmenu work's? - Tyann - 11-03-2016 07:02 PM Bonjour Juste une petite idée, d'amélioration pour une prochaine version. Gérer ces touches de fonctions avec Getkey ou/et ISKEYDOWN Bonne idée ou pas ? Hello Just an idea, improvement for a future release. Manage these function keys with Getkey and/or ISKEYDOWN Good idea or not ? RE: How Drawmenu work's? - StephenG1CMZ - 11-03-2016 08:58 PM (11-03-2016 07:02 PM)Tyann Wrote: Bonjour Bonne idee Checking for a button is much clearer than checking mouse pixels coordinates. I have previously suggested iF button(1) Or If button("Edit") (or whatever your buttons are called) But including it within iskeydown would be ok too. Also useful would be a way of erasing the Drawmenu when you have finished with it: DRAWMENU({}); instead gives 6 empty buttons. RE: How Drawmenu work's? - toml_12953 - 11-04-2016 02:28 PM (11-03-2016 07:02 PM)Tyann Wrote: Bonjour Easter! (Bunny Day - Bonne idée) Tom L RE: How Drawmenu work's? - fabio.hdl - 11-05-2016 08:22 PM (11-03-2016 07:02 PM)Tyann Wrote: Bonjour Yes, it would be much easier handle that with this commands! And thanks to Han for giving this tip! RE: How Drawmenu work's? - primer - 11-11-2016 07:31 PM (11-03-2016 06:41 PM)Han Wrote: It's only a drawing routine. You would have to build your own key handler and interface. Hi, I just published a lib I made to handle events. Please take a look and download my LibMenu. By the way, I made a small program example to show how to do [attachment=4137] This example does require LibMenu, don't forget to install it. hope it can help you. RE: How Drawmenu work's? - compsystems - 11-12-2016 01:36 AM +1 Good program suggestions 1: on the libMenu directory, please write a subroutine to exit the menu 2: A single argument for input as array, PHP Code: { "prg menu x" -> Path of the directory or program ([dirName.]prg([args]) ), If the sublist is empty, black menu (off) sample PHP Code: { 3: Please comment on each line, to learn how the event captures // to manage events, trigger actions PHP Code: EXPORT events() PHP Code: callit(F) RE: How Drawmenu work's? - StephenG1CMZ - 11-12-2016 08:23 AM Primer: Great program, I think*. An obvious improvement in functionality would be to also handle long-clicks, so the user can call two functions from one button, or maybe one function with a mouse-click-type parameter.(Or can it do that already?) Another possibility might be to also handle button events on the main screen, as well as on the bottom row...either by repeating the existing row, or having the user define more buttons. *I haven't used it yet: Android doesnt know what a .hpprgm is, so will not open it for cutting and pasting. RE: How Drawmenu work's? - primer - 11-12-2016 10:41 AM Thank you for your comments, (11-12-2016 01:36 AM)compsystems Wrote: suggestionssorry, I don't understand, can you exaplin what you want ? (11-12-2016 01:36 AM)compsystems Wrote: 2: A single argument for input as array,I make that choice to allow user to modify menu entries on the fly : you can update a menu entry in the WHILE loop without the need to redefine all. also it provide much more flexibility (see below about toggle feature) In general, for this kind of lib, I prefer to have more a kind of "oriented object" process => several methods. (even if it's not a class) IMO, hppl does not provide enough flexibility to create a nice "procedural" oriented process (missing optional function argument). (11-12-2016 01:36 AM)compsystems Wrote: 3: Please comment on each line, to learn how the event capturesThis lib have been made on calc itself, hence not a lot of text, but yes, good idea, next version will have more comment. but as it is now, it's not very difficult to follow yet. (11-12-2016 08:23 AM)StephenG1CMZ Wrote: An obvious improvement in functionality would be to also handle long-clicks, so the user can call two functions from one buttonyes, that's an idea... not for the comming version but one of the next. (11-12-2016 08:23 AM)StephenG1CMZ Wrote: Another possibility might be to also handle button events on the main screen, as well as on the bottom row...either by repeating the existing row, or having the user define more buttons.I already coded something like that : user can have more than 6 entries. in that case the 6th is "next", by pressing "next" libMenu show you the next 5 entries. for your info, on version 2, I am working on a toggle feature. this will allow user to define entries like that Code: LibMenu.entry(3,"caption","function()"); // example of usual menu entry if you have other ideas, you are welcomed. Regards, primer. RE: How Drawmenu work's? - compsystems - 11-12-2016 02:53 PM (11-12-2016 01:36 AM)compsystems Wrote: suggestionssorry, I don't understand, can you exaplin what you want ? To exit the menu, you have to press the [on] key, then "Program interrupted" =( A function is required to exit entry(6,"exit","tstLibM.exitMenu()"); There is a problem, when the menu is on the terminal view. The menu is not updated PHP Code: EXPORT LibMenuTest() PHP Code: callit(F) RE: How Drawmenu work's? - primer - 11-12-2016 08:36 PM (11-12-2016 02:53 PM)compsystems Wrote: To exit the menu, you have to press the [on] key, then "Program interrupted" =(ho.. I see what you mean. but it's not to "exit the menu", it's to exit the WHILE loop, wich is not part of the lib itself. I'm sorry, but it's a misunderstanding of the purpose of LibMenu. The WHILE loop is on the side of the program developer (you), nothing is implemented in LibMenu for that. You have to build your own loop, it's up to you to decide how user can quit (on ESC key press or else ?) I can't do that choice for you : it's your program. There are many way to handle that. For example : Code: local stay:=1; As it is, LibMenu does not stop program execution, then I can't propose a way to "exit the menu" as you asked. Why did I make that choice : to let more freedom to people that use LibMenu, their program are not waiting for user interaction, program continue to run, it can be helpfull for a game for example... (11-12-2016 02:53 PM)compsystems Wrote: There is a problem, when the menu is on the terminal view. The menu is not updated It's not a problem of the lib, but a problem of the program that use it. Your program perform a wait() just after a print() : you are displaying the terminal and stop program execution, what did you expect ? I provided you in that lib a method to refresh your menu : LibMenu.draw(). Feel feel to place a LibMenu.draw() just before your wait(). Every time you clean the screen, it's up to you to redraw the menu. RE: How Drawmenu work's? - compsystems - 11-12-2016 09:05 PM ok Quit function works fine, a delay is required, so the menu does not print n times. PHP Code: callit(F) But unfortunately there is not function to return to the terminal view =(, I hope that some developer will incorporate a function to goto the terminal view (terminalView(); ), also it requires a vertical AutoScroll, otherwise the terminal view is not useful After the first screen. Do you agree with this? please test Menu5 [choose] and menu4 [printScroll] n times PHP Code: //PHP for highlight RE: How Drawmenu work's? - primer - 11-12-2016 10:04 PM (11-12-2016 09:05 PM)compsystems Wrote: But unfortunately there is not function to return to the terminal view =(, I hope that some developer will incorporate a function to goto the terminal view (terminalView(); ), also it requires a vertical AutoScroll, otherwise the terminal view is not useful After the first screen. Do you agree with this?Whatever I agree or not, it's not my concern about LibMenu. And it's not the original topic anymore... Ok, when you choose to use terminal in your program, you have to know the limit of it. and to find how to deal with that. BTW, please note that there is another way to display things on screen : graphics (TEXTOUT), then your program can control scroll. Ok, lets come back to terminal limitations : (11-12-2016 09:05 PM)compsystems Wrote: But unfortunately there is not function to return to the terminal view =(Yes, there is one : PRINT(""); but it add a new (empty) line. (11-12-2016 09:05 PM)compsystems Wrote: also it requires a vertical AutoScrollWhen program ends, it allow user to scroll. But yes, the program cannot control itself the terminal scroll. As I know that limitation, I can stop spaming the terminal after 12 lines, place a wait and clean the terminal. Ok, it's far from perfect... BTW, you can create your own print function that do it for you : untested : Code: local n:=0; // number of printed lines and voilà, you built a lib that enhance your Terminal experiance RE: How Drawmenu work's? - compsystems - 11-14-2016 04:03 AM Thanks Primer is a good idea to program a real terminal view, Who helps me to port my "real terminal view for hp50" to hpprime language? More info http://www.hpmuseum.org/forum/thread-7048.html RE: How Drawmenu work's? - StephenG1CMZ - 11-14-2016 09:03 AM (11-14-2016 04:03 AM)compsystems Wrote: Thanks Primer Compsystems, You might this program useful, or help there: Terminal alternative program http://www.hpmuseum.org/forum/thread-2667.html RE: How Drawmenu work's? - ggauny@live.fr - 01-25-2017 12:11 PM Hi, @ PRIMER, I encounters some problems. LibMenu is into my PRIME but when run : "!", but when I ask VERIFY Prime say : no problem ? May you explain me what I wrong please ? Thanks. RE: How Drawmenu work's? - ggauny@live.fr - 01-25-2017 05:06 PM Hi, In this context, I reproduce a part of program that show us writting good soft boutons with a second level of soft boutons. It is a way to use a "NEXT" "PREV" bouton as on HP 50 for exemple. Reproduced with permission. Code:
Good regards for all. RE: How Drawmenu work's? - primer - 01-25-2017 11:18 PM Hi ggauny, I wanted to modify your program to show how to use with libMenu, but your program can't compile, these functions are missing : N->J(), CALD(), DOE(), and DTM(). to make it compilable, I removed their call, date computation results will not be the expected one. So, I "converted" your program. simply by moving actions into local functions. to demonstrate I simply handle first level menu. You can compare with your program, you will see than main program is no more a bulk of code, each one are now in function. Code:
but to make it work, download the LibMenu |