Alt goes out of focus in a canvas

BlitzMax Forums/BlitzMax Programming/Alt goes out of focus in a canvas

Space Fractal(Posted 2006) [#1]
Im are going to create a application, wich use a windows and a canvas.

When Im using PollEvent as a keyevent, the ALT key(keycode 164) goes just out of focus and get the very dreadfull pulldown menu from the tooleft menu instead.

How can I get red of this problem, so the canvas get the focus alltimes and not trigger the pulldown menu instead?

I even tried something that this without luck (Data got the pulled data event):


If Do$="KeyDown" Then TControllers.KeyD[Data]=1 ; If Data=164 Then ActivateGadget(PaintID)

If Do$="KeyUp" Then TControllers.KeyD[Data]=0 ; If Data=164 Then ActivateGadget(PaintID)


Does this mean ALT cant being used in a BlitzMax game, when using a window?


tonyg(Posted 2006) [#2]
Any runnable example code?


Space Fractal(Posted 2006) [#3]
wx=ClientWidth(Desktop())/2-320
wy=ClientHeight(Desktop())/2-240
WindowID=CreateWindow("Test", wx, wy, 640, 480, Null, WINDOW_TITLEBAR | WINDOW_RESIZABLE | WINDOW_CLIENTCOORDS | WINDOW_ACCEPTFILES)
SetMinWindowSize WindowID, 256, 256
PaintID=CreateCanvas(0, 0, 640, 480, WindowID)

While(True)
	DO$=""
	WaitEvent
	Event$=CurrentEvent.ToString()
	If Left$(Event$,7)<>"Unknown"
		Find=Instr(Event$,":")
		Do$=Left$(Event$, Find-1)

		Find=Instr(Event$,"data=") 
		Find=Find+5
		Find2=Instr(Event$, " ",Find)
		data=Mid$(Event$,Find,Find2-Find-1).ToInt()
	EndIf
	
	If Do$="KeyDown" Then Print "KeyDown: "+Data ; If Data=164 Then ActivateGadget(PaintID)
	If Do$="KeyUp" Then Print "KeyUp: "+Data ; If Data=164 Then ActivateGadget(PaintID)


	Select EventID()
		Case EVENT_WINDOWCLOSE
			End
	End Select
EndWhile


A awfull example, but it work. When pressing ALT, you get the topleft window pulldown (so it dosent pull anymore before pressing ESC).


tonyg(Posted 2006) [#4]
Do you mean when the canvas is supposed to be active but ALT is pressed focus is passed to the menu?
If so, then that *IS* a terrible example as it has no menu.
Anyway, could SetGadgetFilter be used to not pass ALT key presses?


H&K(Posted 2006) [#5]
errr, your example doesnt do what you say the error is.

Edit: oh I see tonyg has pointed that out.

Well, on my Win 1.22 system alt doesnt pull down a menu.


tonyg(Posted 2006) [#6]
Is this the problem?

Notice that 'ALT' causes focus on the FILE menu and away from the canvas and you want to stop this? Is that right?
<edit> Can't use setgadgetfilter as, apparently, it works with textarea and textfield only.


Space Fractal(Posted 2006) [#7]
Yes, it that problem.

When the menu is gone, it just doing that on ms window pulldown menu instead (wich is hidden until you press down).

The pulldown problem is only doing on some windows, like XP. I remember it diddent do that on 98.


H&K(Posted 2006) [#8]
Well I for one would expect any application I was using to jump to the menu system if I pressed alt.

That is you would be removing an essablished method of input, that would be more irritating removed than not removed.

If you dont want a menu system at all do whet you did in your first example. If you do want a menu system, just live with it, cos thats how it works.


Space Fractal(Posted 2006) [#9]
The only problem is ALT is not usable, since it is on use on most MAME setups (mame is a arcade emulator).

Since I use the same default screme as mame, use ALT is used as button 2, wich is a common button.

ALT is also used in most PC games as well.

NB. I do not use a menu, but i would like to kill that hidden menu MS (wich can being seen if DOWN is pressed in my first example).


Space Fractal(Posted 2006) [#10]
Found a way to get rid of it, there is what I did:

wx=ClientWidth(Desktop())/2-320
wy=ClientHeight(Desktop())/2-240
WindowID=CreateWindow("Test", wx, wy, 640, 480, Null, WINDOW_TITLEBAR | WINDOW_RESIZABLE | WINDOW_CLIENTCOORDS | WINDOW_ACCEPTFILES)
SetMinWindowSize WindowID, 256, 256
PaintID=CreateCanvas(0, 0, 640, 480, WindowID)

While(True)
	DO$=""
	WaitEvent
	Event$=CurrentEvent.ToString()
	If Left$(Event$,7)<>"Unknown"
		Find=Instr(Event$,":")
		Do$=Left$(Event$, Find-1)

		Find=Instr(Event$,"data=") 
		Find=Find+5
		Find2=Instr(Event$, " ",Find)
		data=Mid$(Event$,Find,Find2-Find-1).ToInt()
	EndIf
	
	If Do$="KeyDown" Then Print "KeyDown: "+Data ; If Data=164 Then DisableGadget(WindowID)
	If Do$="KeyUp" Then Print "KeyUp: "+Data ; If Data=164 Then EnableGadget(WindowID)


	Select EventID()
		Case EVENT_WINDOWCLOSE
			End
	End Select
EndWhile


Some users may been annoying when window movement is disabled when alt is down, but it only that way to make a workaround.

The otherwice alt should of course work on the menu, if ALT is NOT remapped by the user, but does not doing in that on the new example.

[EDIT]
The only problem is, if the app is in igle, doing some thing, like loading, the pulldown menu is still noticable.

So not a 100% souluation.
[/EDIT]