buttons are not working

BlitzPlus Forums/BlitzPlus Programming/buttons are not working

Heliotrope(Posted 2014) [#1]
Has anyone else had the problem in Blitz Plus 1.47 where you create a few buttons and listboxes and then a canvas with a canvas buffer, only to find that the buttons and listboxes won't work. The problem is fixed by getting rid of the canvas, except that the graphics are necessary. Does anyone know a workaround for this problem ?

startframe = CreateWindow ("Test",200,50,800,600,0,15)
	canframe = CreateCanvas (0,0,GraphicsWidth (),GraphicsHeight (),startframe )
	SetBuffer CanvasBuffer (canframe) 
	selrule1 = CreateListBox (50,50,150,150,startframe)
	selrule2 = CreateListBox (220,50,150,150,startframe)
	okbt = CreateButton ("Ok",320,210,50,30,startframe)
	AddGadgetItem selrule1,"90",0,1
	AddGadgetItem selrule2,"C",1,11
	AddGadgetItem selrule2,"S" ,0,12
	ActivateGadget startframe 
	UpdateWindowMenu startframe
	Repeat 
		
		id = WaitEvent (1)
		If id = $803 Then End 
		If id = $401 Then
			eid = EventData ()
				If EventSource () = okbt Then Exit 
				If eid = 11 Then rule = 11
				If eid = 12 Then rule = 12
			FlushEvents $401
		End If 
		
		Flip 
		Delay 39
		
	Forever 
	FreeGadget startframe



thehawk2323(Posted 2014) [#2]
Don't ever use FlushEvents. You never really need it. You can do everything you want to do with the same exact code, without the FlushEvents function. Try it and tell me if it works :)

Edit:
I tried out the code for myself, and you also need to do "disablegadget(canframe)" after you create it to disable interaction with the user (it will still be visible) so that you can click the buttons, or else it will just think you're clicking on the canvas instead of the button.