WinBlitz3D : Get Active Gadget?!

Blitz3D Forums/Blitz3D Userlibs/WinBlitz3D : Get Active Gadget?!

Hi Kev,

Please check out the example below (run in debug mode to see the feedback). When a gadget triggers an event I expect that that gadget 'has focus' at that time. But when I use _GetActiveGadget() to verify that fact, it tells me otherwise. Do I misunderstand the function, is this normal win api behaviour, or is this a wb3d issue?!??

In stead of the 'active' gadget's handle I get the handle of gadget's parent (ie. the window)...

thanks,

Include "..\..\WB3DStyles.bb"

;| SCHNOK! generated file
;|
;| created: 19 Oct 2006 at 09:59:59
;|
;| note:    test
;|

;gadget globals
Global win1
Global edit1
Global but1

;fonts
Global gui_Project1_font1 = WB3D_OpenFont("Arial",14,0,0,0,0)
Global gui_Project1_default_font = gui_Project1_font1


;----------------------------------------------------------------------------------------
;init
Graphics3D 800,600,0,3
SetBuffer Backbuffer()
Cls


;init WinBlitz3D runtimewindow
Project1 = WB3D_InitializeGUI(SystemProperty("AppHwnd"),0,0,800,600)
WB3D_SetGadgetText Project1, "Test"
WB3D_SetQuitMessage "Test","Sure to Quit?"


;create window(s)
gui_create_win1( 50,55, Project1 )

;reveal gui
WB3D_ShowGadget Project1


;main loop
While Not KeyDown(1)

	event = WB3D_WaitEvent()

	Select event
		Case WB3D_EVENT_KEYPRESS

		Case WB3D_EVENT_MOUSEWHEEL
			;wheelmove will be < 0 when scrolled backwards or > 0 when scrolled forwards
			wheelmove =	WB3D_EventData()

		Case WB3D_EVENT_GADGET

			Select WB3D_EventSource()
				Case edit1
					If WB3D_GetActiveGadget() <> edit1 Then DebugLog "This is not right, is it?!"
					
				Case but1
					If WB3D_GetActiveGadget() <> edit1 Then DebugLog "This is not right, is it?!"

			End Select

		Case WB3D_EVENT_MENU
		Case WB3D_EVENT_WINDOW_CLOSE
		Case WB3D_EVENT_WINDOW_SIZE
		Case WB3D_EVENT_WINDOW_SIZEING
		Case WB3D_EVENT_WINDOW_MOVE
		Case WB3D_EVENT_WINDOW_MOVING
	End Select

Wend

;release & exit
WB3D_EndGUI()
EndGraphics()
End

;----------------------------------------------------------------------------------------

Function gui_create_win1( x, y, parent)

	win1 = WB3D_CreateWindow("New Window",x,y,250,200,parent,-2133917696)
	WB3D_Usefont win1, gui_Project1_default_font

	edit1 = WB3D_CreateEditField("",10,5,160,20,win1,1140854912,0)
	WB3D_SetGadgetExtendedStyle edit1, 512
	WB3D_Usefont edit1, gui_Project1_default_font
	but1 = WB3D_CreateButton("but1",10,30,60,20,win1,1140916224)
	WB3D_Usefont but1, gui_Project1_default_font

End Function


cheers,

Danny

Hi danny,

use the winapi GetFocus() found within user32.dll, does seem theres a problem with winblitz3d's internal WB3D_GetActiveGadget command.

using the example above but1 still fires the active event as its been clicked. and debuglog actives the debugger. i will fix this a.s.p

kev

No problem.

cheers dude,

D