Page 1 of 1

strange behavior about events

Posted: Wed Nov 23, 2016 11:38 am
by Leonhardt
Hello ,I have a PC with a touchscreen, when I run this code,I found a strange behavior:

Code: Select all

OpenWindow(0,0,0,800,600,"",#PB_Window_SystemMenu|#PB_Window_TitleBar|#PB_Window_SizeGadget)

ButtonGadget(0,200,100,100,50,"ok")
CanvasGadget(1,200,250,100,100)
CreateImage(0,100,100)
StartDrawing(ImageOutput(0))
Box(0,0,100,100,0)
StopDrawing()
ImageGadget(2,200,400,100,100,ImageID(0))
Procedure g()
  
  e=EventType()
  g=EventGadget()
  
  If g=1
    If e=#PB_EventType_LeftClick
      Debug "canvas l"
    ElseIf e=#PB_EventType_RightClick
      Debug "canvas r"
    EndIf 
  EndIf 
  If g=0
    Debug "button"
  EndIf 
  If g=2
    If e=#PB_EventType_LeftClick
      Debug "image l"
    ElseIf e=#PB_EventType_RightClick
      Debug "image r"
    EndIf 
  EndIf 
  
  
      
EndProcedure

BindEvent(#PB_Event_Gadget,@g())

  

first:when I touched button, then events occured,but when I touch canvasgadget or imagegadget, nothing happen,
second:when I use traditional mouse to click the canvas gagdet , the left click happens while the right click does'nt, but the image gadget seems normal, both click happens.
Is this a bug or I get something wrong?
Win10,64bit,SB 2.0 beta.you can test my code.Thank you

Re: strange behavior about events

Posted: Wed Nov 23, 2016 12:36 pm
by falsam
Leonhardt wrote:Is this a bug or I get something wrong?
This is a bug.

Try with #PB_EventType_RightButtonDown instead of #PB_EventType_RightClick.

#PB_EventType_RightClick is not detected when it is a CanvasGadget.

:!: Bug repport done. Thanks Leonhardt

Re: strange behavior about events

Posted: Wed Nov 23, 2016 12:50 pm
by Leonhardt
falsam wrote:
Leonhardt wrote:Is this a bug or I get something wrong?
This is a bug.

Try with #PB_EventType_RightButtonDown instead of #PB_EventType_RightClick.

#PB_EventType_RightClick is not detected when it is a CanvasGadget.

:!: Bug repport done. Thanks Leonhardt
Thanks for testing,but I still wonder why touch screen can not trigger click events of canvas and image gadget while button gadget can ,for Android app it is important,I think

Re: strange behavior about events

Posted: Wed Nov 23, 2016 1:05 pm
by falsam
The touch screen detection of button, canvas and image works with Android.
I created an APK with your code. I tested on my Android device. It works.