FXRuby: overload FXSlider

M

Martin

Hi all,

I want to create a custom control which changes the background color
of the slider
whenever an update happens. What's the best way to do this? The
control should behave exactly like FXSilder, so I can not use
connect(). And while I am at it: why doesn't connect() support
multiple message handlers?

regards,
Martin
 
M

Martinus

In that case you could subclass FXSlider and override the default
messages handlers for the SEL_MOTION, SEL_LEFTBUTTONPRESS and
SEL_LEFTBUTTONRELEASE messages.

using connect(), or is there another way?
This may be changed in the near future; someone has recently posted some
code to the fxruby-users mailing list which address that very problem.

I have written a simple solution, which works quite well for me. It
took me exactly 10 minutes - yet another example how elegant Ruby is
:)

class MultiConnectSlider < FXSlider
def initialize(*params)
super(*params)
@sigHandler = Hash.new do |h, n|
h[n] = Array.new
end
end

def connect(signal)
@sigHandler[signal].push Proc.new
super(signal) do |sender, selector, data|
@sigHandler[signal].each do |proc|
proc.call(sender, selector, data)
end
end
end
end
 
M

Martinus

No, you'd need to use the FXMAPFUNC() method to intercept those messages

Thanks!

Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,145
Messages
2,570,824
Members
47,370
Latest member
desertedtyro29

Latest Threads

Top