The usage of HitTestResult class in pygtk webkit -


i write callback function context_menu popup through right-click in order url of link mouse pointing at, know can use webkit.hittestresult class information gdk event(i assume right-click event). however, code below give me nothing.

i find problem may incorrect usage of hittestresult. can find little document talking usage of class, me this?

def callback(self, widget, context_menu, hit_result_event, event):     option = gtk.imagemenuitem('do it')     option.connect('activate', self.option_activate_cb)     context_menu.append(option)     option.show()  def option_activate_cb(self, image_menu_item):     test = webkit.hittestresult()     action = test.props.link-uri     print action 

here example. basically, have use hittestresult.get_link_uri().

from gi.repository import gtk, webkit2  class test:     def __init__(self):         view = webkit2.webview()         view.load_uri('https://stackoverflow.com')         view.connect('context-menu', self.on_context_menu)          win = gtk.window()         win.add(view)         win.connect('delete-event', gtk.main_quit)         win.show_all()      def on_context_menu(self, webview, context_menu, event, hit_test_result):         if hit_test_result.context_is_link():             print(hit_test_result.get_link_uri())  if __name__ == '__main__':     test()     gtk.main() 

Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -