Author Topic: mouseDown/mouseUp/grabDown/grabUp events software vs handheld?  (Read 3485 times)

0 Members and 1 Guest are viewing this topic.

Offline Goran

  • LV2 Member (Next: 40)
  • **
  • Posts: 32
  • Rating: +0/-0
    • View Profile
Hello again,

I am still trying a functionality that works in software, to be also working on handheld. I guess the problem is due to
a bias in my thinking/developing in terms of a desktop and "classic" mouseDown/mouseUp events, compared to handheld's additional grabDown/grabUp events.

(I am aware of handling these events in ETK versions incorporated into FormulaPro (mouseUp/mouseDown) and ETK_Demo_New (grabDown added),
but for now I would like first to understand the bare event sequence both in software and on handheld.)

My goal is either to:
a) to select an object, drag it across the screen and release it at some different location, or
b) to select a point of one object, drag a line across the screen and connect it to a point of another object on release.

This is exactly what we do in Graph app when grabbing a function graph, translate/rotate it by dragging, and release it at different position/orientation,
or when using the slider widget in ETK_Demo_New script.

So,

1) in software (where it works as planned):
 
I implemented the corresponding mouseDown() and mouseUp() handlers, what is for software enough: When I press down and hold the left mouse button, mouseDown(x1,y1) is triggered,
then I drag an object or draw a line by keeping left mouse button pressed, and on the release of the left mouse button mouseUp(x2,y2) is triggered. Nice, works, and cannot be simplier.

2) on the handheld (CX CAS with touchpad):

the most similar (and only possible?) operation is to "grab" the first object (by selecting, holding for a while and releasing the central touchpad button), drag it across the screen
(by dragging across the touchpad) and releasing the object (by clicking shortly on the central touchpad button again).

So, in order to work on handheld, I guess I have to implement additional grabDown(/grabUp?) handler(s).

Based on reading Lua Scripting API manual and some experimenting, I came to the following conclusions (which are not necessarily correct):

a) when I press and hold for a while the central touchpad button, grabDown(0,0) event is created, preceeded by mouseDown(x1,y1) event.
b) on the release of the central touchpad button, grabUp(0,0) event is created (by now, the object is selected/grabbed and ready to be moved around)
c) the manual says that both grabDown() and grabUp() events actively suppress creation of mouseUp() event

To summarize, up to here, grabing my object creates:
   mouseDown(x1,y1)
   grabDown(0,0)
   grabUp(0,0)

Then, dragging the object is done by implementing mouseMove() event.

In the end, if I press shortly the central touchpad button again (to release the object), I guess I'll produce another mouseDown() event.
But my experience shows that:
   i) on pressing shortly the central touchpad button, mouseUp(x,y) handler is used
   ii) the x,y coordinates correspond to the "grabbing" point x1,y1, no matter that I clicked the button at "dragged" position x2,y2.

All this is really puzzling me (to be honest: making a mess in my head)?

Can someone please explain me step by step what really goes on at handheld platform during select-drag-release operation
with regard to events?

Thanks in advance,
Goran

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: mouseDown/mouseUp/grabDown/grabUp events software vs handheld?
« Reply #1 on: August 26, 2013, 10:35:02 pm »
Hi,

By experience, at least on 3.1, the on.grab* events are relatively useless and I'm not sure they guarantee good compatibility accross platforms (well, it's because it's linked to the middle click on the software)

You can easily handle grabbing events by managing some flags within on.mouseUp/Down :)

Here's an example that does exactly that :
http://wiki.inspired-lua.org/Balls_Example

I left there the grabUp event so you can see (put a print) within the software when it's being fired, but without it, the code still works fine on the calc :)
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline Goran

  • LV2 Member (Next: 40)
  • **
  • Posts: 32
  • Rating: +0/-0
    • View Profile
Re: mouseDown/mouseUp/grabDown/grabUp events software vs handheld?
« Reply #2 on: August 29, 2013, 04:15:28 am »
Thanks adriweb,

I see what you mean, mouseDown/mouseUp/grabDown are used just for controlling a grabbing "switch",
the "work horse" here is mouseMove function.

Refreshing approach, this shed a new light! My problem was that I went wrong direction, I put the whole functionality straightforward to mouseUp/mouseDown
(my "work horses").

I'll rewrite the homework now.

Best regards,
Goran

P.S.

BTW, when I copy/pasted the Balls example and ran it on CX CAS, the grabbing worked using Ctrl+Click method only, not using Click+hold selection method
(it's fine with me, I even prefer Ctrl+Click selection: two buttons, but short clicks and 100% success; in the latter case I press and hold Select button,
but many times I release it impatiently too early, then I have to repeat the selection). Nevertheless, Click+hold changes text to "grabbing: true" for a second.