Andy,
Please search on :motionnotify. I see an example in the gears demo. I know that is OpenGL but I am pretty sure all the code you see in there in re event handling is generic to Tk, nothing about OpenGl.
The nise thing about Tk via FFI is the control one gets from low-level access to the event stream. There are rare cases where I feel Tk did not expose enough via an API -- I remember vaguely something about key events, forcing me to code up a virtual event handler -- but as a rule the Tcl/Tk world is your oyster with an FFI based interface.
Gotta run or I would offer more deets.
kt
Andy Chambers wrote:
On Sat, Jul 11, 2009 at 4:35 PM, Kenneth Tiltonkentilton@gmail.com wrote:
Andy Chambers wrote:
Hi,
How would you get the currently focused window in celtk? (I'm trying to write a help bubble that pops up when someone pauses the mouse over a widget for a wee while).
I do a lot of that, but... you are using vanilla Celtk, including Tk widgets? By currently focused window you mean... what, the Tk idea of the current widget? Or the Celtk idea thereof? Or did you mean the toplevel window? Or...
Here's the context...
(defmd root (window) :kids (c? (the-kids (mk-stack (:packing (c?pack-self)) (mk-ui :aeyn) (mk-ui :aeterm) (mk-ui :aestdat)) (mk-canvas :height 200 :background "#ffff99" :kids (c? (the-kids (mk-text-item :coords (list 10 10) :text "Help Text"))) :parent-x 10 :parent-y 20))))
mk-ui is a little utility I have that goes off to look for a "field" definition and knows how to convert that field into celtk objects. Currently, the canvas slots are hard-coded but I'd like the position, size, and contents of this object to change based on where the mouse is. So to answer your question, I think it's Celtk's idea of the current widget that I need.
The way I thought of doing it originally was to add a tk <<Pause>> event and wait for that in the root window. The tcl attached below does this so maybe it's just a case of adding this when the window first starts up. I just wondered if there was a better way of doing it purely in celtk land.
#!/usr/bin/env wish -f
global items # For want of a better name
# I chose Circulate because this is never generated by Tk itself # and I only want to trigger these events myself because Tk doesn't # know when to do it. event add <<Pause>> <Circulate>
bind all <Enter> { global items set id [ after 500 { event generate "%W" <<Pause>> } ] set items("%W") $id }
bind all <Leave> { global items after cancel $items("%W") unset items("%W") }
bind . <<Pause>> { puts "A wee pause just happened on %W..." }
No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.375 / Virus Database: 270.13.10/2231 - Release Date: 07/11/09 05:57:00
On Sat, Jul 11, 2009 at 9:33 PM, Kenneth Tiltonkentilton@gmail.com wrote:
Andy,
Please search on :motionnotify. I see an example in the gears demo. I know that is OpenGL but I am pretty sure all the code you see in there in re event handling is generic to Tk, nothing about OpenGl.
The nise thing about Tk via FFI is the control one gets from low-level access to the event stream. There are rare cases where I feel Tk did not expose enough via an API -- I remember vaguely something about key events, forcing me to code up a virtual event handler -- but as a rule the Tcl/Tk world is your oyster with an FFI based interface.
Cool I've got something working. Just posting it to the list in-case anyone else wants to use it...
The usage would be...
(defmd my-window (window) :kids (c? (the-kids (mk-stack (:packing (c?pack-self)) (mk-label :text "hi" :on-hover (lambda () (trc "hovering...")))))))
The on-hover function only gets called after the mouse has been sitting in the widget for 1 1/2 seconds. The attached patch puts an on-hover slot on the widget class so you should be able to apply to any widget in your hierarchy.
-- Andy
Hi Andy,
thanks for this!
Cheers Frank
Am 12.07.2009 um 00:16 schrieb Andy Chambers:
On Sat, Jul 11, 2009 at 9:33 PM, Kenneth Tiltonkentilton@gmail.com wrote:
Andy,
Please search on :motionnotify. I see an example in the gears demo. I know that is OpenGL but I am pretty sure all the code you see in there in re event handling is generic to Tk, nothing about OpenGl.
The nise thing about Tk via FFI is the control one gets from low-level access to the event stream. There are rare cases where I feel Tk did not expose enough via an API -- I remember vaguely something about key events, forcing me to code up a virtual event handler -- but as a rule the Tcl/Tk world is your oyster with an FFI based interface.
Cool I've got something working. Just posting it to the list in-case anyone else wants to use it...
The usage would be...
(defmd my-window (window) :kids (c? (the-kids (mk-stack (:packing (c?pack-self)) (mk-label :text "hi" :on-hover (lambda () (trc "hovering...")))))))
The on-hover function only gets called after the mouse has been sitting in the widget for 1 1/2 seconds. The attached patch puts an on-hover slot on the widget class so you should be able to apply to any widget in your hierarchy.
-- Andy <hover.patch>_______________________________________________ cells-devel site list cells-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/cells-devel
-- Frank Goenninger
Cell: +49 175 4321058 E-Mail: frgo@me.com