On_Events

Share your advanced PureBasic knowledge/code with the community.
User avatar
idle
Always Here
Always Here
Posts: 5049
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: WaitWindowEventCallBacks()

Post by idle »

Have added a procedure iTrapNativeGadgetEvents() to resolve a range of PB_Event_Types valid for all gadgets
Currently these are only specific for use with EventType_X Callbacks
Note this addition has no affect on OSX

usage
SetEventCallBackGadget(Window,Gadget,*Function,EventType)
where EventType = PB_EventType_x

here's the current list of events valid for any gadget
Prototype EventType_Focus(*userdata=0) ;valid for any gadget
Prototype EventType_LostFocus(*userdata=0) ;valid for any gadget
Prototype EventType_SizeItem(*userdata=0) ;valid for any gadget
Prototype EventType_KeyDown(key.s="",*userdata=0) ;valid for any gadget
Prototype EventType_KeyUP(key.s="",*userdata=0) ;valid for any gadget
Prototype EventType_LeftButtonDown(*userdata=0) ;valid for any gadget
Prototype EventType_LeftButtonUp(*userdata=0) ;valid for any gadget
Prototype EventType_LeftClick(*userdata=0) ;valid for any gadget
Prototype EventType_leftDoubleClick(*userdata=0) ;valid for any gadget
Prototype EventType_MiddleButtonUp(*userdata=0) ;valid for any gadget
Prototype EventType_MiddleButtonDown(*userdata=0) ;valid for any gadget
Prototype EventType_MiddleButtonClick(*userdata=0) ;valid for any gadget
Prototype EventType_MiddleButtonDoubleClick(*userdata=0) ;valid for any gadget
Prototype EventType_MouseEnter(*userdata=0) ;valid for any gadget
Prototype EventType_MouseLeave(*userdata=0) ;valid for any gadget
Prototype EventType_MouseMove(x,y,*userdata=0) ;valid for any gadget
Prototype EventType_MouseWheel(direction,*userdata=0) ;valid for any gadget
Prototype EventType_RightButtonDown(*userdata=0) ;valid for any gadget
Prototype EventType_RightButtonUP(*userdata=0) ;valid for any gadget
Prototype EventType_RightClick(*userdata=0) ;valid for any gadget
Prototype EventType_RightDoubleClick(*userdata=0) ;valid for any gadget


see first post for code
Windows 11, Manjaro, Raspberry Pi OS
Image
User avatar
idle
Always Here
Always Here
Posts: 5049
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: WaitWindowEventCallBacks()

Post by idle »

V 4.2
fixed bugs so it handles multiple windows properly
Added ScreenCallback
Windows 11, Manjaro, Raspberry Pi OS
Image
User avatar
idle
Always Here
Always Here
Posts: 5049
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: WaitWindowEventCallBacks()

Post by idle »

v4.3
turned it into an object

Code: Select all

Define events.On_Events = New_OnEvents() 

procedure Gadget_On_Mouse_wheel(direction,*userdata)
Debug "mouse Scroll " + Str(direction)
EndProcedure    

Procedure Gadget_Mouse_Move(x,y,*userdata) 
   Debug "mouse Move " + Str(x) + " " + Str(y) 
EndProcedure

If events 
    If events\OpenWindow(#Window, 0, 0, 760, 310, "Drag & Drop",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
      ;CreateGadgets...
     ;set events 
      events\Set_EventType_MouseWheel(Window,gadget,@gadget_Mouse_Wheel()) 
      events\Set_EventType_MouseMove(Window,gadget,@gadget_Mouse_Move()) 
     ;start event pump  
     events\DoEvents()
      events\Free() 
    EndIf
Endif   
Windows 11, Manjaro, Raspberry Pi OS
Image
DataMiner
User
User
Posts: 25
Joined: Mon Mar 28, 2005 1:29 pm
Location: Germany

Re: On_Events

Post by DataMiner »

Hi!
I tried your fine Code on Mac OSX 10.6 (PB 5.11 x86) and received an Error: Structure not found: GdkEventAny in On_Events.pbi. What is this Structure for?
Thanks, Tim
I am German - that's hard enough ;)
Mindphazer
Enthusiast
Enthusiast
Posts: 340
Joined: Mon Sep 10, 2012 10:41 am
Location: Savoie

Re: On_Events

Post by Mindphazer »

Same issue here on OSX 10.8
I think that GTK structures are linux APIs
MacBook Pro 14" M1 Pro - 16 Gb - MacOS 14 - Iphone 15 Pro Max - iPad at home
...and unfortunately... Windows at work...
User avatar
idle
Always Here
Always Here
Posts: 5049
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: On_Events

Post by idle »

you need to add

line 396 CompilerElseIf #PB_Compiler_OS = #PB_OS_Linux

might work then on osx
Windows 11, Manjaro, Raspberry Pi OS
Image
Mindphazer
Enthusiast
Enthusiast
Posts: 340
Joined: Mon Sep 10, 2012 10:41 am
Location: Savoie

Re: On_Events

Post by Mindphazer »

idle wrote: might work then on osx
It does ! Except for drag&grop text, but it's a known issue

Thank you Idle
MacBook Pro 14" M1 Pro - 16 Gb - MacOS 14 - Iphone 15 Pro Max - iPad at home
...and unfortunately... Windows at work...
User avatar
Blue
Addict
Addict
Posts: 868
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

Re: On_Events

Post by Blue »

Hello Idle.
Would you create and post a new link to your code file ?
The original link to Ubuntu One Files Service no longer works, since that service has been discontinued.

Thanks
"That's not a bug..." said the programmer. "it's a feature! "
"Oh! I see..." replied the blind man.
User avatar
idle
Always Here
Always Here
Posts: 5049
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: On_Events

Post by idle »

pm'd you the code will fix the link later
Windows 11, Manjaro, Raspberry Pi OS
Image
User avatar
Blue
Addict
Addict
Posts: 868
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

Re: On_Events

Post by Blue »

idle wrote:pm'd you the code will fix the link later
Darn quick reply ! :shock: I'm very impressed.

I got the code. Many thanks.
"That's not a bug..." said the programmer. "it's a feature! "
"Oh! I see..." replied the blind man.
User avatar
idle
Always Here
Always Here
Posts: 5049
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: On_Events

Post by idle »

I'm currently updating it for PB 6.02
code reposted

https://dnscope.io/idlefiles/On_Events.pbi
Post Reply