Canvas buttons, not working!

BlitzMax Forums/BlitzMax GUI Programming/Canvas buttons, not working!

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

The button is attached to the canvas. I wonder if I am not making my point clearly enough here. I am not sure if anyone has fully comprehended the problem?

SuperStrict

Framework		brl.blitz

	Import		brl.standardio
	Import		brl.retro
	Import		brl.bank
	Import		brl.eventqueue
	Import		brl.filesystem
	Import		brl.timer
	Import		brl.system
	Import		brl.jpgloader

?Win32

	Import		brl.d3d7max2d
	Import		brl.win32maxgui
	Import		pub.win32
	
?MacOS

	Import		brl.glmax2d
	Import		brl.cocoamaxgui
	Import		pub.macos

?Linux

	Import		brl.glmax2d
	Import		brl.fltkmaxgui
?


Const WINDOW_WIDTH:Int	= 640
Const WINDOW_HEIGHT:Int	= 480

Const MENU_EXIT:Int		= 104
Const MENU_ABOUT:Int	= 105

Global main_window:Tgadget
Global canvas:TGadget
Global backgrnd:TImage

Global filemenu:TGadget
Global aboutmenu:TGadget


'---------------------------------------------------------------------
If ( Initalise() )
'---------------------------------------------------------------------

	While WaitEvent()

		Select EventID()
		
			Case EVENT_MENUACTION
			
				Select EventData()

					Case MENU_EXIT
						Finalise()
						
					Case MENU_ABOUT
						Notify(  AppTitle + " ©2006", False )
						
					Default
				
				End Select
				
			Case EVENT_WINDOWCLOSE
				If EventSource() = main_window Then Finalise()
			
		
		End Select
					
	Wend
EndIf

Finalise()

'---------------------------------------------------------------------
Function MyHook:Object( iId:Int, tData:Object, tContext:Object )
'---------------------------------------------------------------------

	Local event:TEvent=TEvent(tData)
	If event = Null Return Null
	
	Select event.source

		Case main_window

		Case canvas
		
			Select Event.ID
					
				Case EVENT_GADGETPAINT

					SetGraphics CanvasGraphics(canvas)
					DrawImage backgrnd,0,0
					Flip
					Return Null
					
			EndSelect

	End Select	
			
	Return tData
	
End Function


Const D3DRS_EDGEANTIALIAS:Int=40

'---------------------------------------------------------------------
Function Initalise:Int()
'---------------------------------------------------------------------

?Win32	SetGraphicsDriver D3D7Max2DDriver()
?MacOS	SetGraphicsDriver GLMax2DDriver()
?Linux	SetGraphicsDriver GLMax2DDriver()
?

	backgrnd = LoadImage("resources\background.jpg",FILTEREDIMAGE )

	' Create window and menu.
	CreateFurniture( AppTitle, WINDOW_WIDTH, WINDOW_HEIGHT )

	Return True

End Function


'---------------------------------------------------------------------
Function Finalise()
'---------------------------------------------------------------------

	End

End Function


'---------------------------------------------------------------------
Function CreateFurniture( title:String, width:Int, height:Int )
'---------------------------------------------------------------------
	Local listbox:TGadget

	' Create a centered window with client size WINDOW_WIDTH,WINDOW_HEIGHT
	Local wx:Int=(GadgetWidth(Desktop())-WINDOW_WIDTH)/2
	Local wy:Int=(GadgetHeight(Desktop())-WINDOW_HEIGHT)/2
	
	main_window:TGadget = CreateWindow( title,wx,wy,WINDOW_WIDTH,WINDOW_HEIGHT,Null,WINDOW_TITLEBAR | WINDOW_CLIENTCOORDS | WINDOW_HIDDEN )
	
	canvas:TGadget=CreateCanvas(0,0,WINDOW_WIDTH,WINDOW_HEIGHT,main_window)
	SetGadgetLayout(canvas, 1, 0, 1, 0 )
	
	' Add buttons for canvas	
	CreateButton( "Update", ClientWidth(canvas)-80,ClientHeight(canvas)-58,70,24,canvas,BUTTON_CANCEL )	

	filemenu	=	CreateMenu("&File",		0,WindowMenu(main_window))
					CreateMenu("E&xit",		MENU_EXIT, filemenu, KEY_Q, MODIFIER_COMMAND )

	aboutmenu	=	CreateMenu("Help",		0, WindowMenu(main_window))
					CreateMenu("&About",	MENU_ABOUT, aboutmenu)

	UpdateWindowMenu(main_window)

	AddHook EmitEventHook, MyHook
	
	ShowGadget(main_window)

End Function