Announcement

Collapse
No announcement yet.

img_Touched() - Index returned

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • img_Touched() - Index returned

    Hi,

    The following mechanism is working fine for me to detect an item pressed:

    HTML Code:
    state := touch_Get(TOUCH_STATUS); // get touchscreen status
    x := touch_Get(TOUCH_GETX);
    y := touch_Get(TOUCH_GETY);
    if(state ==  TOUCH_PRESSED)
    n := img_Touched(hndl, -1);                // scan the image list, looking for a touch
    print (n);
    if ( n == 0 )
    Lamps();
    endif
    if ( n == 1 )
    LiquidPumps();
    endif
    .....
    
    
    I would like to know if there's a way to make an explicit relation between the index returned by img_Touched() and the picture/widgets defined in the project. I am planning to make a complexe UI and I would like to use names instead of indexes. I want the code to be robust enought to handle any changes on the UI (pictures or widgets removed) without redefining all conditions regarding the img_Touched mechanism.
    
    So basically what I would like is something as: 
    
    
    state := touch_Get(TOUCH_STATUS); // get touchscreen status
    x := touch_Get(TOUCH_GETX);
    y := touch_Get(TOUCH_GETY);
    if(state ==  TOUCH_PRESSED)
    n := img_Touched(hndl, -1);                // scan the image list, looking for a touch
    print (n);
    if ( n == LampsButton )   //LampsButton is a picture
    Lamps();
    endif
    if ( n == LiquidPumpsButton ) //LiquidPumpsButton is a picture
    LiquidPumps();
    endif
    .....
    Is that feasable?

    Regards,

    Laurent

  • #2


    As per the samples if the object is called AnObject, then its index would be iAnObject. It's defined for you.
    Mark

    Comment

    Working...
    X