Re: Binding images to mouseclicks
- From: elektrikblues@xxxxxxxxx
- Date: Fri, 19 Sep 2008 06:09:33 -0700 (PDT)
On Sep 19, 6:06 pm, elektrikbl...@xxxxxxxxx wrote:
On Sep 18, 7:01 pm, Bruce <doNOTmai...@xxxxxxxxxxx> wrote:
- Hide quoted text -
- Show quoted text -
elektrikbl...@xxxxxxxxx wrote:
hi,copy/paste the entire error message it will tell you where the wrong # args is being applied.
i got an error while trying out the binding of widgets to mouse clicks
on a canvas. the script was as:
bind $my_canvas <1> {
if {%x < $xmax && %y < $ymax} then {
do_widget1
} elseif {%x < $xmax2 && %y < $ymax2} then {
do_widget2
}
}
the error shown is "wrong number of args."
is it not possible to use if-else clause in the command portion of the
"bind" statement? or else can anyone tell me the possible cause and
solutions for this error?
any help is greatly appreciated...
regards,
elektrikblues
the bind command above is syntactically correct and will work - as long as the global variable xmax,
ymax,xmax2,ymax2 exist and do_widget1/do_widget2 are defined and take no arguments.
but the logic seems weird. you say you are trying to bind to an image, but instead you bind
to the canvas itself and do your own intersection (and the intersection logic seems wrong unless
both of you images start at the origin (top left) of the canvas.
The canvs can do all of this work for you. instead of using the system bind on the canvas widget
use the bind sumcommand of the widget and bind directly to you item. Then the canvas handles
all the intersection code.
$my_canvas create image $x $y -image $my_image1 -tag PressMe
$my_canvas bind PressMe <1> do_press
Bruce
hi,
as per your suggestion, i changed the canvas bindings to the
following.
canvas .cns
set selid 11
.cns bind tag1 <1> {
global sid
set sid 11
tk_popup .popupMenu %X %Y
}
.cns bind tag2 <1> {
global sid
set sid 12
tk_popup .popupMenu %X %Y
}
set m [menu .popupMenu]
$m add radiobutton -label 0 -variable x$sid -value "0" -command
{c_process$sid}
$m add radiobutton -label 1 -variable x$sid -value "1" -command
{c_process$sid}
for each tag, i have an independent process as well as an associated
variable that is,
for tag1, the process is "c_process11" and variable is "x11"
for tag2, the process is "c_process12" and variable is "x12"
while running the script, the first binding works fine. but when i
click on the second tag object, the changes are happening to the first
one only. the value of the variable "sid" is not at all being updated
at the global scope. as a result the process still points to
"c_process11" and the variable points to "x11" itself. how can i make
it update itself depending upon the mouseclicks?
pls suggest a solution for this..
thanks in advance,
elektrikblues
oops!!! a newline came in by mistake between the "-command" option and
the associated command in the radiobuttons. pls consider it as a bug
only. :)
elektrikblues
.
- References:
- Binding images to mouseclicks
- From: elektrikblues
- Re: Binding images to mouseclicks
- From: elektrikblues
- Binding images to mouseclicks
- Prev by Date: Re: Binding images to mouseclicks
- Next by Date: Re: default settings for radiobuttons
- Previous by thread: Re: Binding images to mouseclicks
- Next by thread: Re: Binding images to mouseclicks
- Index(es):
Relevant Pages
|