Announcement

Collapse
No announcement yet.

touch detect region

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

  • touch detect region

    I would like to define a detection area of the touch, with touch_DetectRegion function. But once that support is carried out in this area, I can not use the touch, even after using touch_Set (TOUCH_REGIONDEFAULT).

    I would like to disable the first detection zone to put a new Do you have an idea or example to propose to me?

  • #2
    An exemple of my code :

    #platform "uLCD-24PTU"#inherit "4DGL_16bitColours.fnc"#inherit "VisualConst.inc"#inherit "NoName1Const.inc" func menu()var x, y; gfx_BGcolour(0x6906) ; gfx_Cls() ; img_Show(hndl,iWinbutton1) ; img_Show(hndl,iWinbutton2) ; img_Show(hndl, iLeddigits1); img_Show(hndl, iLeddigits2); img_Show(hndl, iLeddigits3); img_Show(hndl, iLeddigits4); img_Show(hndl,iStatictext1) ; img_Show(hndl,iStatictext2) ; img_Show(hndl,iStatictext3) ; img_Show(hndl,iStatictext4) ; img_Show(hndl,iStatictext5) ; img_Show(hndl,iStatictext6) ;repeat touch_DetectRegion(20,0,120,35); if(touch_Get(TOUCH_STATUS) == TOUCH_PRESSED) // scan for touch x := touch_Get(TOUCH_GETX); // get x coordinate y := touch_Get(TOUCH_GETY); // get y coordinate if( (x >= 20 &amp;&amp; x <= 120) &amp;&amp; (y >= 0 &amp;&amp; y <= 35)) // coordinates for Start Button img_SetWord(hndl, iWinbutton1, IMAGE_INDEX, 1); // where state is 0 for up and 1 for down img_Show(hndl,iWinbutton1) ; img_SetWord(hndl, iWinbutton1, IMAGE_INDEX, 0); // where state is 0 for up and 1 for down img_Show(hndl,iWinbutton1) ; endif gfx_Cls(); temperature(); touch_Set(TOUCH_REGIONDEFAULT); endifuntil((x >= 20 &amp;&amp; x <= 140) &amp;&amp; (y >= 0 &amp;&amp; y <= 35));touch_Set(TOUCH_REGIONDEFAULT); endfunc func temperature()var x, y; touch_Set(TOUCH_REGIONDEFAULT); touch_DetectRegion(124,184,78,35); gfx_BGcolour(0x6906) ; gfx_Cls() ; img_Show(hndl,iWinbutton3) ; img_Show(hndl,iStatictext7) ; img_Show(hndl, iLeddigits5); img_Show(hndl,iWinbutton4) ; img_Show(hndl,iWinbutton5) ;repeat if(touch_Get(TOUCH_STATUS) == TOUCH_PRESSED) // scan for touch x := touch_Get(TOUCH_GETX); // get x coordinate y := touch_Get(TOUCH_GETY); // get y coordinate if( (x >= 124 &amp;&amp; x <= 202) &amp;&amp; (y >= 184 &amp;&amp; y <= 219)) // coordinates for Start Button img_SetWord(hndl, iWinbutton1, IMAGE_INDEX, 1); // where state is 0 for up and 1 for down img_Show(hndl,iWinbutton1) ; img_SetWord(hndl, iWinbutton1, IMAGE_INDEX, 0); // where state is 0 for up and 1 for down img_Show(hndl,iWinbutton1) ; endif gfx_Cls(); menu(); touch_Set(TOUCH_REGIONDEFAULT); endifuntil((x >= 124 &amp;&amp; x <= 202) &amp;&amp; (y >= 184 &amp;&amp; y <= 219));touch_Set(TOUCH_REGIONDEFAULT); endfunc func humidite() gfx_BGcolour(0x6906) ; gfx_Cls() ; img_Show(hndl,iWinbutton6) ; img_Show(hndl,iWinbutton7) ; img_Show(hndl,iWinbutton8) ; img_Show(hndl, iLeddigits6); img_Show(hndl,iStatictext8) ;endfunc func main()var hstrings, hFontn, hFontx; // Test carte mémoirevar x, y; // Autres variables du programme gfx_Set(SCREEN_MODE,LANDSCAPE); putstr("Test de présence de la carte memoire\n"); if (!(disk:=file_Mount())) while(!(disk :=file_Mount())) putstr("Carte memoire absente Veuillez en inserer une SVP"); pause(1000); gfx_Cls(); pause(200); wend endif gfx_TransparentColour(0x0020); gfx_Transparency(ON); hFontn := file_LoadImageControl("NoName1.dan", "NoName1.gcn", 1); hstrings := file_Open("NoName1.txf", 'r') ; hndl := file_LoadImageControl("NoName1.dat", "NoName1.gci", 1); gfx_Set(SCREEN_MODE,LANDSCAPE) ; touch_Set(TOUCH_ENABLE); menu();repeatforeverendfunc

    Comment


    • #3


      You code seems to missinterpret the parameters to touch_DetectRegion(), they are x1,y1,x2 and y2, ine place you seem to have understood that, but in the other you seem to have assumed the parameters are x,y,w,h.

      Since you are using an image control why don't you use the 'builtin' img_Touched() function, rather than touch_DetectRegion? It will make your code much easier to write. Maybe have a look at the FancyButtons ViSi example
      Mark

      Comment

      Working...
      X