BindEvent()
BindEvent()
I don't understand the bindevent command with all arguments.
BindEvent(Event, @Callback() [, Window [, Object [, EventType]]])
Is it possible to have samples with Object and EventType?
BindEvent(Event, @Callback() [, Window [, Object [, EventType]]])
Is it possible to have samples with Object and EventType?
Linux Mint 21.1 Vera base: Ubuntu 22.04 jammy.
PureBasic 6.10 LTS (Linux - x64)
PureBasic 6.10 LTS (Linux - x64)
Re: BindEvent()
Maybe you'll get it better through PostEvent() parameters in these examples -> http://www.purebasic.fr/english/viewtop ... 23&t=60552lule wrote:I don't understand the bindevent command with all arguments.
BindEvent(Event, @Callback() [, Window [, Object [, EventType]]])
Is it possible to have samples with Object and EventType?
Re: BindEvent()
http://purebasic.com/documentation/wind ... event.htmllule wrote:I don't understand the bindevent command with all arguments.
BindEvent(Event, @Callback() [, Window [, Object [, EventType]]])
The arguments for Window, Object and EventType limit the scope of the call to BindEvent().
You don't need them if you want one procedure to handle any possible event. On the other hand if you want a procedure to only handle a certain event type (see object type for those allowed) for certain objects (i.e a gadget, menu, or systray) on a certain window then you would use them.
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: BindEvent()
It's all self-explanatory exept Object. Object is a gadget#. In fact it would be more helpful to call it 'gadget' in the doc instead of 'object'.
BERESHEIT
Re: BindEvent()
Thanks for your responses.
I understood Object/#Gadget or #Menu...
Have you a short sample with Object Or And EventType, who work fine?
I understood Object/#Gadget or #Menu...
Have you a short sample with Object Or And EventType, who work fine?
Linux Mint 21.1 Vera base: Ubuntu 22.04 jammy.
PureBasic 6.10 LTS (Linux - x64)
PureBasic 6.10 LTS (Linux - x64)
Re: BindEvent()
I do not know if this helps you...
Code: Select all
Procedure WindowSizer ()
Shared Window, Web
ResizeGadget (Web, 20, 20, WindowWidth (Window) - 40, WindowHeight (Window) - 40)
EndProcedure
Window = OpenWindow (#PB_Any, 100, 100, 200, 200, "Resize it!", #PB_Window_SizeGadget| #PB_Window_SystemMenu)
Web = WebGadget (#PB_Any, 20, 20, WindowWidth (Window) - 40, WindowHeight (Window) - 40, "http://www.google.de/")
BindEvent (#PB_Event_SizeWindow, @ WindowSizer (), Window, Web, #PB_EventType_TitleChange)
Repeat
Select WaitWindowEvent ()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
If EventGadget() = Web And EventType() = #PB_EventType_TitleChange
SetWindowTitle (Window, "Window size = " + Str (WindowWidth (Window)) + "x" + Str (WindowHeight (Window)))
WindowSizer ()
EndIf
EndSelect
ForEver

Re: BindEvent()
it's help, but it's not working!
after resizing the window, webgadget is not resizing.
after resizing the window, webgadget is not resizing.
Linux Mint 21.1 Vera base: Ubuntu 22.04 jammy.
PureBasic 6.10 LTS (Linux - x64)
PureBasic 6.10 LTS (Linux - x64)
Re: BindEvent()
You need to type something into Google's search text input and press enter to trigger the resize. Sorry, but i found no better way to demonstrate it. Maybe somebody else can set this right, my skills are incomplete here. 


Re: BindEvent()
es_91,
if you test your code without bindevent, It's work too.
if you test your code without bindevent, It's work too.
Code: Select all
Procedure WindowSizer ()
Debug "WindowSizer"
Debug EventGadget()
Shared Window, Web
ResizeGadget (Web, 20, 20, WindowWidth (Window) - 40, WindowHeight (Window) - 40)
EndProcedure
Window = OpenWindow (#PB_Any, 100, 100, 700, 200, "Resize it!", #PB_Window_SizeGadget| #PB_Window_SystemMenu)
Web = WebGadget (#PB_Any, 20, 20, WindowWidth (Window) - 40, WindowHeight (Window) - 40, "http://www.google.de/")
;BindEvent (#PB_Event_SizeWindow, @ WindowSizer (), Window, Web, #PB_EventType_TitleChange)
Repeat
Select WaitWindowEvent ()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
If EventGadget() = Web And EventType() = #PB_EventType_TitleChange
SetWindowTitle (Window, "Window size = " + Str (WindowWidth (Window)) + "x" + Str (WindowHeight (Window)))
WindowSizer ()
EndIf
EndSelect
ForEver
Linux Mint 21.1 Vera base: Ubuntu 22.04 jammy.
PureBasic 6.10 LTS (Linux - x64)
PureBasic 6.10 LTS (Linux - x64)
Re: BindEvent()
I post what i want to do
Code: Select all
Structure tagGADGETAMOI
hTypeID.i
hWindow.i
hGadget.i
EndStructure
Procedure __GadgetAMoi_Resize()
Protected *pGadget.tagGADGETAMOI
If IsGadget(EventGadget())
*pGadget.tagGADGETAMOI = GetGadgetData(EventGadget())
If *pGadget
ResizeGadget(*pGadget\hGadget, -1, -1, WindowWidth(*pGadget\hWindow) * 0.9, WindowHeight(*pGadget\hWindow) * 0.9)
EndIf
Else
EndIf
EndProcedure
Procedure GadgetAMoi(hID, x, y, Width, Height, Value.s)
Protected *pGadget.tagGADGETAMOI = AllocateMemory(SizeOf(tagGADGETAMOI))
If hID = #PB_Any
*pGadget\hGadget = StringGadget(#PB_Any, x, y, Width, Height, Value)
Else
StringGadget(hID, x, y, Width, Height, Value)
*pGadget\hGadget = hID
EndIf
SetGadgetData(*pGadget\hGadget, *pGadget)
*pGadget\hWindow = GetActiveWindow()
;Here the gadget will resize wen his window is resize
BindEvent(#PB_Event_SizeWindow, @__GadgetAMoi_Resize(), *pGadget\hWindow, *pGadget\hGadget)
EndProcedure
Global.i Lfenetre, Lgadget
Lfenetre = 322
Lgadget = Lfenetre-16
; Shows possible flags of StringGadget in action...
If OpenWindow(0, 0, 0, Lfenetre, 205, "StringGadget Flags", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget)
StringGadget(1, 8, 10, Lgadget, 20, "Normal StringGadget...")
GadgetAMoi(2, 8, 35, Lgadget, 20, "1234567")
StringGadget(3, 8, 60, Lgadget, 20, "Read-only StringGadget", #PB_String_ReadOnly)
StringGadget(4, 8, 85, Lgadget, 20, "lowercase...", #PB_String_LowerCase)
StringGadget(5, 8, 110, Lgadget, 20, "uppercase...", #PB_String_UpperCase)
StringGadget(6, 8, 140, Lgadget, 20, "Borderless StringGadget", #PB_String_BorderLess)
StringGadget(7, 8, 170, Lgadget, 20, "Password", #PB_String_Password)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Linux Mint 21.1 Vera base: Ubuntu 22.04 jammy.
PureBasic 6.10 LTS (Linux - x64)
PureBasic 6.10 LTS (Linux - x64)
- BasicallyPure
- Enthusiast
- Posts: 539
- Joined: Thu Mar 24, 2011 12:40 am
- Location: Iowa, USA
Re: BindEvent()
hi lule,
The problem with your code is that you cannot use the 'object' option in BindEvent()
when the event is #PB_Event_SizeWindow.
The event is not coming from the string objects, it is coming from the window.
Try this code and see that if you include the 'object' parameter it will not work.
BP
The problem with your code is that you cannot use the 'object' option in BindEvent()
when the event is #PB_Event_SizeWindow.
The event is not coming from the string objects, it is coming from the window.
Try this code and see that if you include the 'object' parameter it will not work.
BP
Code: Select all
Procedure Callback()
Debug "resize event"
EndProcedure
OpenWindow(0,0,0,200,100,"",#PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_ScreenCentered)
StringGadget(1,10,10,100,25,"ABC123XYZ")
;BindEvent(#PB_Event_SizeWindow,@Callback(),0,1) ; <-- does not work this way
BindEvent(#PB_Event_SizeWindow,@Callback(),0) ; <-- this works
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
BasicallyPure
Until you know everything you know nothing, all you have is what you believe.
Until you know everything you know nothing, all you have is what you believe.
Re: BindEvent()
Thank you all for your support.
Linux Mint 21.1 Vera base: Ubuntu 22.04 jammy.
PureBasic 6.10 LTS (Linux - x64)
PureBasic 6.10 LTS (Linux - x64)