Post Reply 
MOUSE command CLICK type
02-24-2018, 10:08 PM
Post: #14
RE: MOUSE command CLICK type
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:

// Input handler for keyboard and touch screen
// by Giancarlo Cotrufo
// feb 24, 2018


EXPORT WEIT()
BEGIN
  RECT;
  LOCAL dat, ctr;
  LOCAL T0Y, T1Y, DY;
  LOCAL T0X, T1X, DX;
  REPEAT
   dat:=B→R(WAIT(-1)); // the dat variable store the keyboard/mouse event
   RECT;
   ctr:=ctr+1; // the ctr variable store the number of keyboard/mouse events
   TEXTOUT_P(dat,20,50,2);
   TEXTOUT_P(ctr,20,65,2);
   IF TYPE(dat)≠6 THEN TEXTOUT_P("KEY " + dat(),20,80,2); // phisical keyboard event
   ELSE // touch screen event
      IF dat(1)==0 THEN T0Y:=dat(3); T0X:=dat(2); END; // mouse down
      IF dat(1)==1 THEN T1Y:=dat(3); T1X:=dat(2); // mouse move on the touch screen
        CASE // detect direction of drag/swipe
          IF T1Y-T0Y>3 THEN TEXTOUT_P("DRAG ⇓  ",20,95,2); WAIT(.5); END;
          IF T1Y<T0Y THEN TEXTOUT_P("DRAG ⇑  ",20,95,2); WAIT(.5); END;
          IF T1X>T0X THEN TEXTOUT_P("DRAG ⇒ ",20,95,2); WAIT(.5); END;
          IF T1X<T0X THEN TEXTOUT_P("DRAG ⇐ ",20,95,2); WAIT(.5); END;
        DEFAULT
        END;
      END;
      IF dat(1)==3 THEN // normal click on the screen
         TEXTOUT_P("CLICK",20,80,2);
         IF dat(3)>219 THEN // detect the soft menu part of the screen
           TEXTOUT_P("CLICK MENU " + (1+IP(dat(2)*6/320)),20,80,2); //show which soft menu has been pressed
         END; // soft menu branch
      END // click branch
    END // keyboard/touch screen branch
  UNTIL 0; // loop
END;

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
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
MOUSE command CLICK type - Giancarlo - 01-25-2018, 09:59 PM
RE: MOUSE command CLICK type - Carlos295pz - 01-25-2018, 10:37 PM
RE: MOUSE command CLICK type - Giancarlo - 01-25-2018, 11:40 PM
RE: MOUSE command CLICK type - Carlos295pz - 01-26-2018, 12:30 AM
RE: MOUSE command CLICK type - Giancarlo - 01-26-2018, 06:23 PM
RE: MOUSE command CLICK type - Carlos295pz - 01-26-2018, 07:34 PM
RE: MOUSE command CLICK type - Giancarlo - 01-27-2018, 04:22 PM
RE: MOUSE command CLICK type - Carlos295pz - 01-27-2018, 04:32 PM
RE: MOUSE command CLICK type - Carlos295pz - 01-26-2018, 07:52 PM
RE: MOUSE command CLICK type - Giancarlo - 01-27-2018, 06:35 PM
RE: MOUSE command CLICK type - Giancarlo - 01-29-2018, 08:16 PM
RE: MOUSE command CLICK type - Giancarlo - 02-24-2018 10:08 PM
RE: MOUSE command CLICK type - Tyann - 03-04-2018, 11:08 AM
RE: MOUSE command CLICK type - Carlos295pz - 03-04-2018, 11:46 AM
RE: MOUSE command CLICK type - Tyann - 03-04-2018, 05:11 PM
RE: MOUSE command CLICK type - Carlos295pz - 03-04-2018, 07:50 PM
RE: MOUSE command CLICK type - Tyann - 03-06-2018, 05:58 AM
RE: MOUSE command CLICK type - Giancarlo - 03-04-2018, 09:11 PM
RE: MOUSE command CLICK type - Carlos295pz - 03-04-2018, 10:20 PM



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