[fxruby-users] mdiclient windows do not always activate on click
Joel VanderWerf
vjoel at path.berkeley.edu
Fri Apr 27 18:13:24 EDT 2007
Joel VanderWerf wrote:
> I just noticed that MDIClient windows do not automatically become
> current when they receive a mouse click, but only do so if the click
> happens inside of an enabled widget. This may very well be correct, but
> if so then what is the right way to handle it, if you want a more
> familiar window-manager behavior (click to focus)?
>
> For example, if you change the mditest.rb example like so...
>
> --- mditest.rb 2007-04-18 16:19:59.000000000 -0700
> +++ mdi.rb 2007-04-27 14:44:54.000000000 -0700
> @@ -134,7 +134,7 @@
> scrollwindow = FXScrollWindow.new(mdichild, 0)
> scrollwindow.verticalScrollBar.setLine(@font.fontHeight)
> btn = FXButton.new(scrollwindow, TYGER,
> - :opts => LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT, :width => 600,
> :height => 1000)
> + :opts => LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT, :width => 100,
> :height => 100)
> btn.font = @font
> btn.backColor = FXColor::White
> mdichild
>
>
> ...and then click on the empty area within one of the windows behind the
> active child, then that window will not be made active.
>
> However, adding the line
>
> scrollwindow.enabled = true
>
> makes the behavior feel more normal (to me).
>
> Is there any drawback to enabling things like scroll windows (probably
> also frames and matrixes, but I haven't tried them)?
>
> Is there a better way to handle this?
>
Here's a candidate. In the FXMDIChild's create method, enable the
content window (which I guess is everything but the title bar and
border), and handle mousedown:
def create(*)
super
contentWindow.enable
contentWindow.connect(SEL_LEFTBUTTONPRESS) do
parent.setActiveChild self
false
end
end
Unfortunately, a mouse click in (for example) a label inside of the
content window doesn't get caught this way. Still looking for something
better...
--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407
More information about the fxruby-users
mailing list