Hi.
i'm creating a dialog that finds out what is focused element. that's what i wrote:
import gtk
import gobject
class FocusedElementPath(gtk.Dialog):
def __init__(self, parent, title=None):
gtk.Dialog.__init__(self, title or 'Show path', parent)
self.catch_within = parent
self.catch_focus = True
self.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
again_btn = gtk.Button('',gtk.STOCK_REFRESH)
again_btn.connect('activate', self.refresh_pressed)
again_btn.show()
self.action_area.add(again_btn)
self.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
self.action_area.set_layout(gtk.BUTTONBOX_EDGE)
self.path = gtk.Label()
self.path.show()
self.vbox.add(self.path)
def refresh_pressed(self, btn):
self.catch_focus = True
def do_focus_out_event(self, evt):
nl = self.catch_within.get_focus()
if nl:
self.catch_within.activate_focus()
self.path.set_text(repr(nl))
else:
self.path.set_text('None')
gtk.Dialog.on_focus_event(self, evt)
gobject.type_register(FocusedElementPath)
the problem is it returns previously focused element. is there any way to find out currently focused element? i've tried different events (for dialog and for window), but nothing helped :( what am i doing wrong or how do i do this correctly?