MOUSE command CLICK type - 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: MOUSE command CLICK type (/thread-10019.html) Pages: 1 2 |
MOUSE command CLICK type - Giancarlo - 01-25-2018 09:59 PM Hello, with the following code i am able to detect the key (the ENTER key in this example) to stop the program and some gestures on the touch screen. What is making me mad is that i can detect the DRAG, the ROTATE and STRETCH but I am not able to detect the simple CLICK! In reality this is not true since, when i click on the menu RUN to execute the program, it automatically detect a CLICK and then, for the rest of execution i am not able to reproduce again. At the moment i am interested in the single CLICK not the LONG one... Code:
Any hint? Thanks Giancarlo RE: MOUSE command CLICK type - Carlos295pz - 01-25-2018 10:37 PM There are 2 ways to program interfaces, the easy one and the difficult one so to speak. 1 ° Event-based: WAIT (-1) It recognizes screen and keyboard, it does not execute instructions if an event or 60s does not occur. (Single key press, click, long click, drag, rotate, zoom) 2 ° Based on fixed cycles: WAIT (.005) ?, MOUSE, GETKEY, |ISKEYDOWN| The recognition algorithm must be programmed, long click not implemented. The most recommended is to use mainly WAIT (-1), is it necessary to use mode 2? You can use both ways, in order to cover all the needs, WAIT (-1) usually fulfills everything necessary unless it is something similar to a GAME. RE: MOUSE command CLICK type - Giancarlo - 01-25-2018 11:40 PM Hello Carlos, thanks for your feedback. In reality i tried to work with MOUSE since i tried to work with the WAIT(-1) command with no luck as well. With WAIT i am able to detect the menu Keys, the CLICK, but i am not able to detect the MOVE (the direction of MOVE) since i'd like to understand where the user is moving the finger... Another code snippet... Code:
Thanks Giancarlo RE: MOUSE command CLICK type - Carlos295pz - 01-26-2018 12:30 AM The screen events by WAIT (-1) are not unique, a behavior can have up to 3 values in buffer, it explores the values that each action returns, I also see your code a little messy, the conditionals must be located just where you are going to use it , it is not convenient at all to use returns and then compare them again, unless this code is a simple actions explorer. The location of the RETURN also does not seem appropriate, so you can not get the following events. RE: MOUSE command CLICK type - Giancarlo - 01-26-2018 06:23 PM Hello Carlos, i removed everything not needed to the execution of the project. If you look at the code it should just detect a click and print it on the screen for 2 seconds when detected. For a strange reason i don't know, the click is detected only when launching the program and clicking on the RUN soft menu. Code:
Why i am not able to detect a click in upper part of the screen? it seems the CLICK is detected only when clicking in the soft menu area... My final goal, for other programs i would need are the management of: - soft menu click (and that works) - DRAG (a swipe) and that works - click in the upper part of the screen (area different from the menu)... Thanks Giancarlo RE: MOUSE command CLICK type - Carlos295pz - 01-26-2018 07:34 PM MOUSE returns these types: 0: Click 1: Click in menu zone 2: Drag 3: Zoom 4: Rotate 7: Problematic type I think that would look good: Code: EXPORT MAUZ_2() RE: MOUSE command CLICK type - Carlos295pz - 01-26-2018 07:52 PM Working with MOUSE, GETKEY and ISKEYDOWN is only recommended when requiring animations or similar, as in games, otherwise it is more optimal to work with WAIT (-1). I have not yet written an article on interface creation, but I have published a short introduction at the end of a graphic article: Introduction to GUIs (Spanish). If you want to explore WAIT(-1), try this code: Code: EXPORT WAIT_1_TEST It is not necessary to convert the coordinates # 0:-16h to real data, you can compare them directly without problems. Using ISKEYDOWN or GETKEY can cause operating problems in WAIT (-1), however its use ends up being unnecessary. RE: MOUSE command CLICK type - Giancarlo - 01-27-2018 04:22 PM Hello Carlos, Thank you very much for your help which is highly apreciated. Using the MOUSE code above which is definitely more elegant than mine, there is never the possibility to detect mouse TYPES like 2, 3 or 4 since TYPE=0 being a mouse down, it is always triggered before turning into a DRAG, ROTATE. Am i wrong? Are you able to detect mouse types different than 0 or 1? For my application i would need to detect a CLICK (which is a selection of item in my application) and a DRAG (which is a LIST scroll in my application). Thanks Giancarlo (01-26-2018 07:34 PM)Carlos295pz Wrote: MOUSE returns these types: RE: MOUSE command CLICK type - Carlos295pz - 01-27-2018 04:32 PM (01-27-2018 04:22 PM)Giancarlo Wrote: Am i wrong? Are you able to detect mouse types different than 0 or 1? It is possible, if you need that the same area detects a click and a drag at the same time, you must create an algorithm that detects a finished click, otherwise you can separate each action according to the zone pressed, dividing the screen into small areas greatly facilitates its programming. This is not a problem with all the events that WAIT(-1) returns, I recommend that you use it in replacement of the other action recognition commands RE: MOUSE command CLICK type - Giancarlo - 01-27-2018 06:35 PM THank you very much. Thanks for the link you provided yesterday. The amount of work you did is incredible on the graphical interfaces. I think that your interfaces are astonishing! Really a good job. It’s in spanish but italian is not different from spanish so i was able to understand the content. Thanks again Giancarlo (from cappuccino state) RE: MOUSE command CLICK type - cyrille de brébisson - 01-29-2018 07:09 AM Hello, MOUSE (and ISKEYDOWN) vs WAIT(-1). These 2 functions seems very similar, but do slightly different things. WAIT is an EVENT function. Meaning that it returns events which are waitable on. Waitable event are great because, while waiting, the CPU is in low power mode. Events represent "instantaneous" data. This includes "key press" or "click". Events are placed in an event queue and 'consumed' or removed one at a time. MOUSE and ISKEYDOWN are much more continuous and return "state" data. current X/Y position for a mouse cursor for example. Internally, state data is "interpreted" to generate events. However, the "interpreter" will add some meta data to the data to remember what is has decided in the past. Some of that info might be returned by MOUSE (I do not remember exactly), which might lead to confusion. A mouse 'gesture' comes from interpreting the state data and should be aquired through a WAIT function. This should help you decide what function to use. For the specifics (from memory, so I might have some details wrong). One trick that I have put in place is that "windows" (the calculator graphics is based on graphic windows) can give some hints to the gesture interpreter. Among other things, it can tell: 'I only accept clicks'. In this case, a mouse down imediately generates a click without having to wait for the mouse up. This is usefull as it gives the impression of faster UI. This is used in some windows like the menus. This is why when mousing in the menu area you can never get mouse move or similar events. Hope this helps. Cyrille RE: MOUSE command CLICK type - Giancarlo - 01-29-2018 08:16 PM Hello Cyrille, Thank you very much for your comments. Now i better understand when to use one command than another. I was writing a small program able to mimic the behaviour of the internal program showing the list of programs or list of note. Everything fine with the keys detection until i tried also to detect the click (to select one item of the list) and scrolls up and down to show the - hidden - part of the list scrolling it. Are internal routines written in hppl or they were written in other language? If Hppl how it was possible to manage the click event distinguished from the scroll? I know that CLICK and DRAG are different gestures, however it is not possible to detect which one was clicked and in case of DRAG in which direction? Thanks Giancarlo RE: MOUSE command CLICK type - cyrille de brébisson - 01-30-2018 06:13 AM Hello, Click and Drag event are mutually exclusive. A Down, with Moves that stay in the area of the down, followed by an UP will generate a Click. A Down, with local moves and with no UP within the following 2/3 of a second will generate a long click. A Down, with moves that go over a certain disctance will start generating drags until the UP event. Now, if the moves were fast enough, then extra moves (kinetik drags) will be generated to give a "momentum" effect. Cyrille RE: MOUSE command CLICK type - Giancarlo - 02-24-2018 10:08 PM Hello Cyrille, thanks for the suggestion. it works very well. This is the small code snippet i used to detect: - keyboard press - mouse move (up, down, left, right) - click out of menu area - click in the menu area and soft menu numer (1->6) Code:
Something interesting is that the mouse move on the touch screen creates 3 events for the WAIT command; thanks CARLOS for pointing out this feature. Thanks Cyrille for explaining that the menu area for speed purpose just detect the click event. I can understand this feature however i could see a benefit in detecting a swipe (mouse move) in that soft menu area to mimic the PREV/NEXT command... Thanks for all the explanation Giancarlo RE: MOUSE command CLICK type - cyrille de brébisson - 02-26-2018 06:00 AM Hello, I understand what you mean. One day, I might have to do something along these lines.... Maybe implement variable size menus too! Cyrille RE: MOUSE command CLICK type - Tyann - 03-04-2018 11:08 AM Bonjour Ce poste est très intéressant, personnellement en utilisant WAIT(-1) dans un programme pour détecté soit un click soit un glisser je me suis retrouvé confronté à un problème. L'événement glisser a tendance à être détecté plusieurs fois, voici un peu l'architecture de mon programme: Hello This post is very interesting, personally using WAIT (-1) in a program to detect either a click or a drag I found myself facing a problem. The drag event tends to be detected several times, here is a little architecture of my program: Code:
le click fonctionne très bien. Le remède que j'ai trouvé insérer Code: WHILE MOUSE(4)<>-1 END; Code: n:=8 On voit d'ailleurs bien un temps de latence plus ou moins long selon l'amplitude du glisser. Question peut-on vider le buffer de WAIT(-1) instantanément avec une instruction une fois nos événements acquis ? The problem is that for a single drag the 2 rounds of loop For t execute while only 1 should do it. the click works very well. The remedy I found insert [code] WHILE MOUSE (4) <> - 1 END; [/ code] before [code] n: = 8 [/ code] in ch_de which I think must clear the buffer of WAIT ( -1). We also see a latency time more or less long depending on the amplitude of the slide. Question can we clear the buffer of WAIT (-1) instantly with an instruction once our events acquired? RE: MOUSE command CLICK type - Carlos295pz - 03-04-2018 11:46 AM I do not have problems with the drag of WAIT(-1), I think you should not use the WHILE function if you have a REPEAT, not is necessary 2 loops RE: MOUSE command CLICK type - Tyann - 03-04-2018 05:11 PM (03-04-2018 11:46 AM)Carlos295pz Wrote: I do not have problems with the drag of WAIT(-1), I think you should not use the WHILE function if you have a REPEAT, not is necessary 2 loops Bonjour Carlos295p Merci pour vôtre réponse, vous avez raison c'est logique la boucle while de la fonction ch_de peut être supprimée. Je viens de le faire et cela fonctionne. Malheureusement je suis toujours confronté au même problème, j'ai bien pensé à la vitesse d'exécution (je me suis déjà fait avoir) mais même en ralentissant avec un WAIT(n) le glisser se répéte quand même. D'ailleurs si je place un WAIT(-1) avant la boucle For t pour figer l'écran et que je fais un glisser pour lancer la boucle celui-ci déclenche un événement glisser dans ch_de. Hello Carlos295p Thank you for your answer, you're right it's logical the while loop of function ch_de can be removed. I just did it and it works. Unfortunately I still face the same problem, I thought about the speed of execution (I'm already having) but even slowing down with a WAIT (n) drag is repeated anyway. By the way, if I put a WAIT (-1) before the For t loop to freeze the screen and I drag to start the loop it triggers a drag event in ch_de. RE: MOUSE command CLICK type - Carlos295pz - 03-04-2018 07:50 PM It is a little complicated to understand the situation of double displacement, could you make a small video showing it? RE: MOUSE command CLICK type - Giancarlo - 03-04-2018 09:11 PM Hello, The issue i had with my code in the previous post is that if you swipe in a direction which is not perfectly horizontal and vertical, the current code could detect a wrong direction. If i had to adjust the code i should define a threshold to remove the possible wrong swipes. Carlos, which app you use to record the videos? Thanks Giancarlo |