From: Andrew B. <And...@cs...> - 2007-11-07 12:38:15
|
I have an application where I want to use the up/down/left/right arrow keys to navigate around an expression displayed on-screen. I also want the window to have scrollbars. However when I hit an arrow key, the expression navigation works fine, but the scrolled window also moves ! How do I stop these key events getting to the scrollbars ? (I only want to scroll using the mouse.) The wxWidgets documents talk about preventing event propagation using wxEvent::Skip, but I can't find a wxHaskell equivalent of this. -- -------------------------------------------------------------------- Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204 Foundations and Methods Research Group Director. Course Director, B.A. (Mod.) in CS and ICT degrees, Year 4. Department of Computer Science, Room F.13, O'Reilly Institute, Trinity College, University of Dublin, Ireland. http://www.cs.tcd.ie/Andrew.Butterfield/ -------------------------------------------------------------------- |
From: shelarcy <she...@gm...> - 2007-11-08 09:14:47
|
Hi Andrew, On Wed, 07 Nov 2007 21:39:44 +0900, Andrew Butterfield <And...@cs...> wrote: > However when I hit an arrow key, the expression navigation works fine, > but the scrolled window also moves ! > > How do I stop these key events getting to the scrollbars ? > > (I only want to scroll using the mouse.) > > The wxWidgets documents talk about preventing event propagation > using wxEvent::Skip, but I can't find a wxHaskell equivalent of this. wxHaskell has propagateEvent function that is wrapper function of wxEvent::Skip. How about use it? http://wxhaskell.sourceforge.net/doc/Graphics.UI.WX.Events.html#v%3ApropagateEvent Best Regards, -- shelarcy <shelarcy hotmail.co.jp> http://page.freett.com/shelarcy/ |
From: Andrew B. <And...@cs...> - 2007-11-08 09:22:07
|
shelarcy wrote: > Hi Andrew, > > On Wed, 07 Nov 2007 21:39:44 +0900, Andrew Butterfield <And...@cs...> wrote: > >> However when I hit an arrow key, the expression navigation works fine, >> but the scrolled window also moves ! >> >> How do I stop these key events getting to the scrollbars ? >> >> (I only want to scroll using the mouse.) >> >> The wxWidgets documents talk about preventing event propagation >> using wxEvent::Skip, but I can't find a wxHaskell equivalent of this. >> > > wxHaskell has propagateEvent function that is wrapper function of wxEvent::Skip. > How about use it? > > http://wxhaskell.sourceforge.net/doc/Graphics.UI.WX.Events.html#v%3ApropagateEvent > because it says: *propagateEvent* :: IO () Pass the event on the next /wxWindows/ event handler, either on this window or its parent. Always call this method when you do not process the event. (This function just call skipCurrentEvent <http://wxhaskell.sourceforge.net/doc/Graphics.UI.WXCore.Events.html#v%3AskipCurrentEvent>). I want to do the opposite - handle the event in the frame where the expression is displayed, but not send it to whatever is handling the scroll bars My code - for the relevant windows > -- Goal Window > gp <- panel h [] > g <- scrolledWindow gp [] Do I need to nest another window inside the scrolled window ? When I perform the right-arrow action (say), I repaint g, which renders the expression appropriately. My biggest problem is that the documentation is very unclear. -- -------------------------------------------------------------------- Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204 Foundations and Methods Research Group Director. Course Director, B.A. (Mod.) in CS and ICT degrees, Year 4. Department of Computer Science, Room F.13, O'Reilly Institute, Trinity College, University of Dublin, Ireland. http://www.cs.tcd.ie/Andrew.Butterfield/ -------------------------------------------------------------------- |
From: shelarcy <she...@gm...> - 2007-11-21 07:41:18
|
Hi Andrew, I'm sorry about my reply is late. Do you already solve this problem? On Thu, 08 Nov 2007 18:23:40 +0900, Andrew Butterfield <And...@cs...> wrote: > My code - for the relevant windows > > > -- Goal Window > > gp <- panel h [] > > g <- scrolledWindow gp [] > > Do I need to nest another window inside the scrolled window ? > When I perform the right-arrow action (say), I repaint g, > which renders the expression appropriately. Is gp a panel? I don't know why you don't want to set key events for panel instead of scrolledWindow. I think you can skip key events for scrolledWindow by propagateEvent, if you set key events for panel. > My biggest problem is that the documentation is very unclear. I think problems come from poor examples. Can you send us more complete - executable - example code? Your problem is unclear for me. Best Regards, -- shelarcy <shelarcy hotmail.co.jp> http://page.freett.com/shelarcy/ |
From: Andrew B. <And...@cs...> - 2007-11-21 17:02:16
|
shelarcy wrote: > Hi Andrew, > > I'm sorry about my reply is late. > Do you already solve this problem? > > On Thu, 08 Nov 2007 18:23:40 +0900, Andrew Butterfield <And...@cs...> wrote: > >> My code - for the relevant windows >> >> > -- Goal Window >> > gp <- panel h [] >> > g <- scrolledWindow gp [] >> >> Do I need to nest another window inside the scrolled window ? >> When I perform the right-arrow action (say), I repaint g, >> which renders the expression appropriately. >> > > Is gp a panel? > > I don't know why you don't want to set key events for panel > instead of scrolledWindow. I think you can skip key events > for scrolledWindow by propagateEvent, if you set key events > for panel. > OK - I see what you mean - I thought that as I had to paint to g that I needed to catch keystrokes there - but of course these are independent of the painting - so I see what you are suggesting. I solved the problem in a different way - I started experimenting in another window and discovered the following. If, in g (above) I handle arrow keys with individual handler like so: set g [ on downKey := .... ; on upKey := ... ... ] then hitting the down-arrow keys triggers my handler and that for the scrollbars. However if I set a single handler for all keys which then does a case analysis of keys, as follows:, then the scroll bars are not affected by the arrow keys. set g [ on anyKey := handleKeys ... ] handleKeys ... k = case k of KeyDown -> .... KeyUp -> ... -- -------------------------------------------------------------------- Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204 Foundations and Methods Research Group Director. Course Director, B.A. (Mod.) in CS and ICT degrees, Year 4. Department of Computer Science, Room F.13, O'Reilly Institute, Trinity College, University of Dublin, Ireland. http://www.cs.tcd.ie/Andrew.Butterfield/ -------------------------------------------------------------------- |