Tk event_generate broken?

P

Phlip

Rubies:

I suspect this Ruby version has a broken event_generate.

ruby 1.8.2 (2004-07-29) [i386-mswin32]

(Feel free to suggest the problem is between the keyboard and chair...)

Below my signature is a mail I posted many moons ago, which I claimed
worked.

I will go back to an old version and see if the problem persists.

--
Phlip
http://industrialxp.org/community/bin/view/Main/TestFirstUserInterfaces

require "tk"


def main

top = TkRoot.new
canvas = TkCanvas.new (top)
canvas.grid('row'=>0, 'column'=>0, 'sticky'=>'ew')
canvas.configure('width' => 200, 'height' => 500)

shape = [30, 30, 30, 60, 60, 30 ]

poly1 = TkcPolygon.new(canvas, shape) {
fill 'green'
}

poly1.bind ('Button-1') {
puts 'yo'
poly1.configure('fill' => 'red')
Tk.event_generate(poly1, 'Button-1') # <-- yo
}
Tk.update
Tk.event_generate(poly1, 'Button-1')
Tk.update
Tk.mainloop

end
 
H

Hidetoshi NAGAI

Hi,

From: "Phlip" <[email protected]>
Subject: Tk event_generate broken?
Date: Wed, 18 Aug 2004 01:55:57 +0900
Message-ID: said:
poly1 = TkcPolygon.new(canvas, shape) {
fill 'green'
}

poly1.bind ('Button-1') {
puts 'yo'
poly1.configure('fill' => 'red')
Tk.event_generate(poly1, 'Button-1') # <-- yo
}
Tk.update
Tk.event_generate(poly1, 'Button-1')

Unfortunately, if you want to generate events for canvas items,
you must give the coordinate information of the event.
(e.g. Tk.event_generate(poly1, 'Button-1', :x=>36, :y=>36) )
When the target of Tk.event_generate method is a canvas item,
the generated event is sent to the canvas widget which includes
the target item, because Tcl/Tk's event command can't send events
to canvas items directly. It depends on the coordinate of the event
whether the canvas calls the callback procedure of the target item
or not.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top