Page 1 of 1

TrackBarGadget events

Posted: Thu Nov 11, 2010 11:21 pm
by tinman
Hi all,

I'm messing about with a TrackBarGadget and there only seems to be one way to get events from it, which I've hacked up below. Basically you get an event from the gadget and use GetGadgetState(). Anything better than what I've got?

Code: Select all

EnableExplicit

Define.l event
Define.l quit : quit = 0

If OpenWindow(0, 0, 0, 800, 600, "foo", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_TitleBar|#PB_Window_ScreenCentered)

  TrackBarGadget(0, 10, 10, 400, 20, 0, 100)


  While Not(quit)
    event = WaitWindowEvent()
    Select event
      Case #PB_Event_CloseWindow
        quit = 1
      Case #PB_Event_Gadget
        If EventGadget() = 0
          Debug GetGadgetState(0)
        EndIf
    EndSelect
  Wend
  
  CloseWindow(0)
EndIf
End
When I click somewhere in the trackbar other than the thumb, or use page up/down I get two events with the same value. Is that meant to happen? Easy enough to filter out anyway.

Is it possible to get events whether the thumb has been pressed or released in a cross platform way? I've searched the forums and every suggestion has been Windows only. I really need the cross platform aspect, so while API solutions would be OK they'd have to be for each platform (and I don't have a Mac or enough Linux knowledge) so I'd prefer a PB method.

I think I know what the answer will be, so any chance of getting these events added (mods feel free to move this to feature requests in that case ;)

Cheers.

Re: TrackBarGadget events

Posted: Tue Dec 21, 2010 3:03 am
by IdeasVacuum
Have thought about defining your own track bar gadget? It's probably the easiest way to ensure it does what you want it to do. Essentially the track is an image and the bar an image button.

Re: TrackBarGadget events

Posted: Fri Dec 24, 2010 6:51 pm
by tinman
Thanks for the suggestions. However, I'd like to (or would have like to) use PB commands for cross platform support.

I have since found out that the underlying OS events just seem to come through unmodified, and what I am trying to get is the value of the trackbar when it is released. So on Windows I get the two events (which is fine, I can filter it out as necessary) and on Linux I get events when the thumb moves, regardless of when the value changes.

It doesn't look like I can detect the release of the thumb on Linux using PB code, so I'll just need to have my application behave differently.

Cheers.