TextField Focus Loss

BlitzMax Forums/BlitzMax GUI Programming/TextField Focus Loss

Hi,
When I have focus on a TextField and press the Enter button,
the TextField looses focus, and if I try to use ActivateGadget on it right away it'll just loose focus instantly again.

I've tried using SetGadgetFilter, but the Enter button will not show up.

Anyone know how to solve this?

Strict

Local WW:Int = 200
Local WH:Int = 50
Local WX:Int = GadgetWidth(Desktop())/2-WW/2
Local WY:Int = GadgetHeight(Desktop())/2-WH/2
Global MainWindow:TGadget = CreateWindow( "Testing.", WX, WY, WW, WH, Null, WINDOW_TITLEBAR | WINDOW_CLIENTCOORDS )

Global MainWindowInput:TGadget = CreateTextField( 5, 5, 190, 20, MainWindow )
Global MainWindowBtn:TGadget = CreateButton( "Click", 5, 25, 190, 20, MainWindow, BUTTON_OK )

ActivateGadget( MainWindowInput )

Repeat
	If PeekEvent()<>Null
		WaitEvent()
		Select EventID()
			Case EVENT_WINDOWCLOSE
				End
			Case EVENT_GADGETACTION
				Select EventSource()
					Case MainWindowBtn
						SetGadgetText( MainWindowInput, "" )
						ActivateGadget( MainWindowinput )
				End Select
		End Select
	EndIf
	
	Delay 2
	
Forever



Just enter a text and press Enter, the textfield will loose focus and will not get it back even though I use ActivateGadget when the button gets pressed.

How it should work is that the Textfield should get focus again, but it doesn't for me..

Thanks

Tried it in OSX and the textfield remains in focus after Enter.

-David

Works OK on WinXP BMax 1.24 with full syncmods.

Appears to work on GTKMaxGUI on Linux too : pressing Enter leaves focus on the text field.

It's strange, I removed all modules and re-downloaded them from Synchronize Modules, and still doesn't work.

Anyone have an idea on what could be wrong? :/

Oh, And I'm using WinXP SP2, with BMax 1.24.

Thanks :)

Do you have 'Quick Build' turned on? Gives sometimes strange effects, so turn it off.
And try to delete the .bmx folder where your source file is located.

I never use 'Quick Build', Tried the Delete .bmx folder thing, Didn't work either :/
It has always been like this, I remember trying to create a chat application a long time ago, had the same problem then. Very annyoing :S

Any more ideas? :P

Thanks

I tried the example on 2 other machines, WinXP no SP and WinXP SP1, same thing happens there, TextField looses focus when I press enter. So it's not only my machine it happens on.

No clues? :/

Thanks :)

I also am seeing the Text Field lose the focus. No idea why...

After playing with this a bit more. I found that pressing Enter in a text field causes it to lose focus. So, my guess is the problem you are seeing is the order of events.

Your button is getting the Enter press, then your text field is getting the enter press. When the button gets the enter press, it clears the box and gives it focus, but then I think the text field is then getting the enter press which causes it to lose focus.

Funny thing is, the text field does not give any events when it gets the enter press except EVENT_GADGETLOSTFOCUS. I tried this without the button and the text field loses focus on Enter, sends the EVENT_GADGETLOSTFOCUS and that is it.

Had another look and I *do* lose focus.
I think this has been reported before though
here
Not sure how it got put in the bugbin although BRL did get purge bug reports so they could start again some time ago.

Thanks for looking things up a bit TaskMaster,
I've come up with a 'Hack' solution to the problem.

Strict

Local WW:Int = 200
Local WH:Int = 50
Local WX:Int = GadgetWidth(Desktop())/2-WW/2
Local WY:Int = GadgetHeight(Desktop())/2-WH/2
Global MainWindow:TGadget = CreateWindow( "Testing.", WX, WY, WW, WH, Null, WINDOW_TITLEBAR | WINDOW_CLIENTCOORDS )

Global MainWindowInput:TGadget = CreateTextField( 5, 5, 190, 20, MainWindow )
Global MainWindowBtn:TGadget = CreateButton( "Click", 5, 25, 190, 20, MainWindow, BUTTON_OK )
Global ButtonPressed:Int = 0

ActivateGadget( MainWindowInput )

Repeat
	If PeekEvent()<>Null
		WaitEvent()
		Select EventID()
			Case EVENT_WINDOWCLOSE
				End
			Case EVENT_GADGETACTION
				Select EventSource()
					Case MainWindowBtn
						SetGadgetText( MainWindowInput, "" )
						ButtonPressed = 1
				End Select
		End Select
	EndIf
	
	If ActiveGadget() <> MainWindowInput
		If ButtonPressed = 1
			ActivateGadget( MainWindowInput )
			ButtonPressed = 2
		ElseIf ButtonPressed = 2
			ActivateGadget( MainWindowInput )
			ButtonPressed = 0
		EndIf
	EndIf
	
	Delay 2
	
Forever


Just in case anyone else experience this problem and want to solve it.

Thanks :)