I created a simple form (600x600) with only two objects.
- DrawingArea1
- Button1
Super simple... the idea is that if I click the button, it draws a line. Should be eazy-peasy... but I just don't understand what Gambas wants from me.
' Gambas class file
' Variables
Public x1 As Integer = 5
Public y1 As Integer = 5
Public x2 As Integer = 15
Public y2 As Integer = 15
Public mytask As Integer = 0
Public Sub Form_Open()
End
Public Sub form_Close()
End
Public Sub Button1_Click()
mytask = 1
x1 = 100
y1 = 100
x2 = 150
y2 = 150
DrawingArea1_Draw
End
Public Sub DrawingArea1_Draw()
Draw.Begin(DrawingArea1)
If mytask = 0 Then ' <-- This works (automatically)
Draw.Line(x1, y1, x2, y2)
Endif
If mytask = 1 Then ' <-- This fails ( Can not paint outside of DRAW event handler )
Draw.Line(x1, y1, x2, y2)
Endif
Draw.End
End
When run, the routine sees that mytask = 0 and it draws a small line... Apparently the Public Sub DrawingArea1_Draw() runs automatically when the form opens. Ok... I get that.When I click the button, I reset the variables and tell it to run the routine again... crash and burn.
I was like... Ok... maybe I thought that I needed to put the Draw.Begin(DrawingArea1) in the Public Sub Form_Open() and the Draw.End in the Public Sub Form_Close()... nope... CRASH again.
If I can get Gambas to do something graphical when I press a button... then there is hope that I can do stuff on a slider change, or a timer activation... can someone help me please???