Bug or my incompetence lol :)

Just starting out? Need help? Post your questions and find answers here.
User avatar
Zebuddi123
Enthusiast
Enthusiast
Posts: 794
Joined: Wed Feb 01, 2012 3:30 pm
Location: Nottinghamshire UK
Contact:

Bug or my incompetence lol :)

Post by Zebuddi123 »

Hi to All.

Something davido posted caught my eye and as I was thinking about mk-soft`s question and playing with davido`s code I came across this. Now I`m sure some of you guys would know or it would be a challenge for you to sort the answer out. ( probably my misunderstanding as usual :lol:)

In the code below: the canvasgadget messages are received ie: 65538 - #pb_eventtype _mousemove and 65539.#pb_eventtype_mouseleave. Not 65587 #pb_eventtype_mouseenter.

Should it not be mouseenter and mouseleave ? also messages are only returned when entering the canversgadget from the right. nothing from left, up, down. As I`ve said probably me being thick :lol: but i`m still learning in my defense.

Zebuddi. :

Code: Select all


  CompilerIf #PB_Compiler_Unicode
    #XmlEncoding = #PB_UTF8
  CompilerElse 
    #XmlEncoding = #PB_Ascii
  CompilerEndIf

  #Dialog = 0
  #Xml = 0
  Global XML$, Event.i
  
  
  
  
  Runtime Enumeration Windows
    #WinMain
    
  EndEnumeration
  Runtime Enumeration Gadgets
    #CanvasCDrop
EndEnumeration

   
  
 
  
;---- Zebuddi......
Runtime Procedure setup()
	EnableGadgetDrop(#CanvasCDrop, #PB_Drop_Text, #PB_Drag_Copy)
EndProcedure

Runtime Procedure gettext()
	Debug "GadgetID: " + Str(EventGadget()) + " eventtype: " + Str(EventType())
	If ((EventGadget() = #CanvasCDrop) And  (EventDropType() = #PB_Drop_Text))
		MessageRequester(Str(EventGadget()), EventDropText())
	Else
		Debug "nope"
	EndIf
EndProcedure
  ;-----------------
  
  XML$ = "<dialogs>"+
         "  <window id='#WinMain' name='CTest' text='CTest Drop' minwidth='auto' minheight='auto' flags='#PB_Window_ScreenCentered |"+
         "  #PB_Window_SystemMenu | #PB_Window_SizeGadget'>" +
         "    <canvas id='#CanvasCDrop' width='200' height='200' onevent='gettext()'/>"+
         "  </window>"+
         "</dialogs>"
  
  If CatchXML(#Xml, @XML$, StringByteLength(XML$), 0, #XmlEncoding) And XMLStatus(#Xml) = #PB_XML_Success
    
  	If CreateDialog(#Dialog) And OpenXMLDialog(#Dialog, #Xml, "CTest")
  		
  		setup()
  		
  		;---- Zebuddi......
  		BindGadgetEvent(#CanvasCDrop, @gettext(), #PB_EventType_LeftClick)
  		;-----------------

      Repeat
        Event = WaitWindowEvent() : Until Event = #PB_Event_CloseWindow 
      
    Else  
      Debug "Dialog error: " + DialogError(#Dialog)
    EndIf
  Else
    Debug "XML error: " + XMLError(#Xml) + " (Line: " + XMLErrorLine(#Xml) + ")"
  EndIf
malleo, caput, bang. Ego, comprehendunt in tempore
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4637
Joined: Sun Apr 12, 2009 6:27 am

Re: Bug or my incompetence lol :)

Post by RASHAD »

Hi Zebuddi123
#pb_eventtype_mouseenter = 65537
Change to:

Code: Select all

BindGadgetEvent(#CanvasCDrop, @gettext(), #PB_All)
You get all events as usual
Egypt my love
Post Reply