Click vs Touch

enonod

Well-Known Member
Licensed User
Longtime User
It has taken me a long time to find 'some kind' of feeling for the difference between Touch and Click. I could not find it on B4A, where it 'seems' to be taken for granted. One aspect 'appears' to revolve around whether a touch screen is present (Tablet/phone) or not (Android TV).
My question is... is that the most important criterion for deciding between two views that might do a similar job?

simple i.e., to use a square that can be touched to change its colour. It could be a Button, Label, Imageview etc.

[Edit] There would appear to be a requirement in the Android Market that non touch screen devices are not supported so does that mean that Click may be unsupported in some circumstances?

Is there a fuller explanation available in the documentation that I have been unable to find via searching using those keywords?
 
Last edited:

klaus

Expert
Licensed User
Longtime User
Click and Touch are events raised by the operating system.
You use the Click event if you just want to do something when the user just touches the view (or clicks on it) like a Button.
You use the Touch event if you want to do something when the user moves the finger on the view.
In Basic4Android not all views expose the two events.
For example a Button has only the Click event.
But a Panel has both.
If you want you could also program your own Click and LongClick events in a Touch event.
You can add events not exposed in Basic4Android with the Reflection library.

Best regards.
 
Upvote 0

enonod

Well-Known Member
Licensed User
Longtime User
Thank you klaus for the clarification
The (now, obviously misleading, to me) information I read suggested that if Touch were used the program would not work on a non touch screen device whereas a Click would work on both but either event could be used to press a button.

If you want you could also program your own Click and LongClick events in a Touch event.
is the above comment dependent upon this comment...
You can add events not exposed in Basic4Android with the Reflection library.
or are you saying there are two ways?
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Touch and Click event have nothing to do with the kind of screen.
It depends on the input device(s).
On my Asus TF700 I have a keyboard with a touch pad.
The Click and Touch events work with both input methods. When the keyboard is connected I can work with both at the same time like on a notebook with a mouse and the touch pad.
I don't know if you are familiar with VB.
The Click event is the same as the Click event in VB.
The Touch event is similar to the MouseDown, MouseMove and MouseUp events in VB. The difference is in Android there is one event handling the three actions, in VB there are three event routines.

If I remember well you can have only one of the two events at the same time in B4A. So if you need both you must handle a Click or a LongClick event in the Touch routine.

If you really want for example the Touch event for an ImageView you could add it with the reflection libary.

Best regards.
 
Upvote 0

enonod

Well-Known Member
Licensed User
Longtime User
Perfectly clear thank you klaus
 
Upvote 0

mjtaryan

Active Member
Licensed User
Longtime User
Okay, I now understand all this. But, is there any full documentation that describes the touch event? Are there any specific methods associated with it? Thanks.
 
Upvote 0
Top