Skip to content

Commit

Permalink
touchring: prevent touchring to remain visible when using multi/virtu…
Browse files Browse the repository at this point in the history
…al keyboard + fix touch grabbing issue when window is used. Closes kivy#1335
  • Loading branch information
tito committed Oct 16, 2013
1 parent 2fbaf43 commit b92276b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
5 changes: 5 additions & 0 deletions kivy/core/window/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from kivy.properties import ListProperty, ObjectProperty, AliasProperty, \
NumericProperty, OptionProperty, StringProperty
from kivy.utils import platform, reify
from kivy.context import get_current_context

# late import
VKeyboard = None
Expand Down Expand Up @@ -481,6 +482,10 @@ def __init__(self, **kwargs):
# manage keyboard(s)
self.configure_keyboards()

# assign the default context of the widget creation
if not hasattr(self, '_context'):
self._context = get_current_context()

# mark as initialized
self.initialized = True

Expand Down
15 changes: 12 additions & 3 deletions kivy/modules/touchring.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ def _touch_down(win, touch):
size=(iw * pointer_scale, ih * pointer_scale),
texture=pointer_image.texture)

if not ud.get('tr.grab', False):
ud['tr.grab'] = True
touch.grab(win)


def _touch_move(win, touch):
ud = touch.ud
Expand All @@ -59,9 +63,14 @@ def _touch_move(win, touch):


def _touch_up(win, touch):
ud = touch.ud
win.canvas.after.remove(ud['tr.color'])
win.canvas.after.remove(ud['tr.rect'])
if touch.grab_current is win:
ud = touch.ud
win.canvas.after.remove(ud['tr.color'])
win.canvas.after.remove(ud['tr.rect'])

if ud.get('tr.grab') is True:
touch.ungrab(win)
ud['tr.grab'] = False


def start(win, ctx):
Expand Down

0 comments on commit b92276b

Please sign in to comment.