Skip to content
This repository has been archived by the owner on Jan 11, 2018. It is now read-only.

Commit

Permalink
Extend init to on_console_message and execute_javascript
Browse files Browse the repository at this point in the history
In order to trig js functions from within kivy
And get triggers through on_console_message from the webpage to kivy
  • Loading branch information
triselectif committed Oct 30, 2011
1 parent e9f4efd commit f1d8a78
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion berkelium/__init__.py
Expand Up @@ -347,6 +347,18 @@ def get_bk(self):
updated. Use self.texture.size instead.
'''

#AW
last_console_message = ObjectProperty( None )
'''Stores the last console message sent by the webpage. A 'on_console_message' event is fired when
a new console message happens. It enables the app to get backward triggers coming from the webpage.
Composed of (message, source_id, line_no)
:data:`last_console_message` is a :class:`~kivy.properties.ObjectProperty`, default to
None.
'''
#end AW

def __init__(self, **kwargs):
_init_berkelium()

Expand All @@ -372,6 +384,7 @@ def __init__(self, **kwargs):
self.register_event_type('on_widget_move')
self.register_event_type('on_widget_paint')
self.register_event_type('on_paint')
self.register_event_type('on_console_message')#AW
super(Webbrowser, self).__init__(**kwargs)
if self.url is not None:
self.open_url(self.url)
Expand Down Expand Up @@ -640,6 +653,13 @@ def can_go_forward(self):
'''
return self._bk.canGoForward()

#AW
def execute_javascript(self, string):
'''Pass some js code to be executed in the window
'''
return self._bk.executeJavascript(string)
#end AW

# default handlers
def on_start_loading(self, url):
pass
Expand All @@ -656,8 +676,10 @@ def on_crashed_plugin(self, plugin_name):
def on_provisional_load_error(self, url, error_code, is_main):
pass

#AW
def on_console_message(self, message, source_id, line_no):
pass
self.last_console_message = (message, source_id, line_no)
#end AW

def on_script_alert(self, message, default_value, url, flags, success):
pass
Expand Down

0 comments on commit f1d8a78

Please sign in to comment.