On 04/03/11 23:37, Hans-Christoph Steiner wrote:
I'm trying to think if there is a way to keep or get the coordinates of
the object itself. On the C-side there is, plus when an object is
created or edited then the GUI knows the location of it. Here's how, in
your pdtk_text_editing, you just need to query the coords of the active
text widget. This is a rough attempt that just gets a menu popping up:

proc pdtk_text_editing {mytoplevel tag editing} {
set tkcanvas [tkcanvas_name $mytoplevel]
set rectcoords [$tkcanvas coords ${tag}R]
if {$rectcoords ne ""} {
set x [expr int([lindex $rectcoords 0])]
set y [expr int([lindex $rectcoords 1] - 20)]
pdtk_post "currently editing at: $x $y\n"
if {! [winfo exists .completepopup] } {
menu .completepopup
.completepopup add command -label mod -command bell
.completepopup add command -label moses -command bell
}
tk_popup .completepopup $x $y
}
if {$editing == 0} {
selection clear $tkcanvas
# auto-completion
set ::completions {}
set ::new_object false
set ::lock_motion false
set ::cycle false
} {
set ::editingtext($mytoplevel) $editing
# auto-completion
set ::new_object $editing
}
$tkcanvas focus $tag
}

hi Hans
dunno if this is the same for you but for me there are some issues with this (on Archlinux + fluxbox):

- the popup is created at "screen coordinates" and not patch window ones, i.e. if the object box is at 100x25 (from the top-left patch window), the popup appears at 100x25 from the top-left corner of my whole screen, which I find not very intuitive

- also, if you are creating an object with CTRL-1 and moving your mouse (no click), the coordinates don't update (but that's not that bad)

anyway, all these are the reasons why I dropped the popup option (which would be better IMHO).

I'll think a bit more about it in the next days.

cheers,
_y

_______________________________________________
Pd-list@iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list

Reply via email to