Sense if a spinner control has been in any way touched

Skip to first unread message

Tom Farrell

Feb 1, 2023, 7:00:40 PMFeb 1
to DroidScript
I'm sure this is very simple but I don't know the answer.  Is there a way to sense whether a spinner control has been in any way clicked?  I don't mean whether a selection has been made. Just that the user has touched the spinner control in order to start scolling in order to make a selection. 

I suspect this can be generalized to whether there is a way to sense whether ANY control has been in any way touched?

The reason why I want to be able to sense this is pretty dull -- I have developed a DroidScript app which works just fine -- however, I want to refine its UI in certain ways. I can elaborate but it could get unnecessarily verbose.



Feb 2, 2023, 4:00:42 AMFeb 2
to DroidScript
You can track this using each control SetOnTouchs methods if they have one, otherwise you can wrap your control in a spy layout that will capture the touch events:

function OnStart() {
    var lay = app.CreateLayout( "Linear", "FillXY,VCenter" );
    var laySpy = app.AddLayout( lay, "Linear", "TouchSpy" );
    laySpy.SetOnTouchDown( laySpy_OnTouchDown );
    var spin = app.AddSpinner( laySpy, "one,two,three", 0.5 );
    spin.SetOnChange( spin_OnChange );
    app.AddLayout( lay );

function laySpy_OnTouchDown() {
    app.ShowPopup( "spinner touched down!", "Short" );

function spin_OnChange( item ) {
    app.Alert( item, "Spinner item" );

Reply all
Reply to author
0 new messages