Hi, I think that the event EVENT_GADGETPAINT used by Canvas prevents anything from being updated while it's in progress. This behavior is most probably only on Mac OS, because on WinXP I didn't had this 'bug' in my app.
Here's the code:
You'll see UpdateSlider at two differents place: in the example shown (inside GADGETPAINT), nothing happens if you click and drag the mouse around. However, if you resize the window, the slider and window title will get updated. Seems like the gadgets are 'dirty' but don't get drawn.
If you comment UpdateSlider and then uncommented the one in EVENT_MOUSEMOVE, then the program behaves correctly: the slider should move when you click and drag.
Can anyone confirm?
Here's the code:
SuperStrict Global MainWindow:TGadget = CreateWindow("Click and drag mouse to move slider", 100, 100, 400, 300) Global MainCanvas:TGadget = CreateCanvas(0,0,300,200, MainWindow) Global Slider:TGadget = CreateSlider(0,240,400,15, MainWindow, SLIDER_HORIZONTAL | SLIDER_SCROLLBAR) SetSliderRange(slider, 50, 250) Global global_slide_pos:Int = 0 AddHook EmitEventHook,MyHook Repeat WaitEvent() If EventID() = EVENT_APPTERMINATE Or EventID() = EVENT_WINDOWCLOSE Then End Forever Function MyHook:Object(iId:Int,tData:Object,tContext:Object) Local Event:TEvent=TEvent(tData) If Event.source=MainCanvas And Event.ID=EVENT_GADGETPAINT ' Update here: it doesn't work! UpdateSlider() Return Null EndIf If Event.ID=EVENT_MOUSEMOVE If(event.data = 1) Then global_slide_pos = event.x ' Update here: it works! 'UpdateSlider() EndIf EndIf Return tData End Function Function UpdateSlider() SetSliderValue(slider, global_slide_pos) SetGadgetText(MainWindow, "Slider pos="+ global_slide_pos) End Function
You'll see UpdateSlider at two differents place: in the example shown (inside GADGETPAINT), nothing happens if you click and drag the mouse around. However, if you resize the window, the slider and window title will get updated. Seems like the gadgets are 'dirty' but don't get drawn.
If you comment UpdateSlider and then uncommented the one in EVENT_MOUSEMOVE, then the program behaves correctly: the slider should move when you click and drag.
Can anyone confirm?