|
|
2009-07-08
, 19:31
|
|
|
Posts: 2,427 |
Thanked: 2,986 times |
Joined on Dec 2007
|
#2
|
...
def __init__(s, aScrolledWindow, ...):
...
s.sw = aScrolledWindow
s.oldx = -1
s.oldy = -1
...
s.connect('button-press-event', s.on_button_press)
s.connect('motion-notify-event', s.on_motion)
...
def on_button_press(s, view, event):
...
s.oldx = event.x
s.oldy = event.y
...
def on_motion(s, view, event):
...
sw = s.sw
if event.x != s.oldx:
aux = sw.props.hadjustment.value + s.oldx - event.x
if sw.props.hadjustment.lower <= aux and \
aux <= sw.props.hadjustment.upper - sw.props.hadjustment.page_size:
sw.props.hadjustment.value = aux
if event.y != s.oldy:
aux = sw.props.vadjustment.value + s.oldy - event.y
if sw.props.vadjustment.lower <= aux and \
aux <= sw.props.vadjustment.upper - sw.props.vadjustment.page_size:
sw.props.vadjustment.value = aux
s.oldx = event.x
s.oldy = event.y
...
...
|
|
2009-07-08
, 21:03
|
|
Posts: 146 |
Thanked: 15 times |
Joined on Oct 2008
|
#3
|
|
|
2009-07-10
, 14:48
|
|
Posts: 146 |
Thanked: 15 times |
Joined on Oct 2008
|
#4
|
|
|
2009-07-10
, 15:23
|
|
Posts: 882 |
Thanked: 1,310 times |
Joined on Mar 2007
|
#5
|
|
|
2009-07-10
, 15:38
|
|
Posts: 105 |
Thanked: 48 times |
Joined on Aug 2008
|
#6
|
# Disable focus for all widgets, so we can use the cursor
# keys + enter to directly control our media player, which
# is handled by "key-press-event"
for w in (
self.rrewind_button, self.rewind_button,
self.play_pause_button, self.forward_button,
self.fforward_button, self.progress,
self.bookmarks_button, self.volume_button, ):
w.unset_flags(gtk.CAN_FOCUS)
|
|
2009-07-10
, 16:34
|
|
|
Posts: 2,427 |
Thanked: 2,986 times |
Joined on Dec 2007
|
#7
|
For some reason, your on_motion function didn't work for me. It didn't even enter in the function...
But never mind, I decided to make another approach using a variation of your code (clicking in the image bring that pixel to the center of the widget).
But I have another question, if you don't mind: clicking in the arrows of the D-PAD cycles the focus through the widgets of the app. I want to use the D-PAD for better purposes, but it keeps moving the focus, even if I do some "...grab_focus". How I completely disable this focus cycle properties of the D-PAD?
Thanks a lot!!
L.
myWidget.add_events(gtk.gdk.POINTER_MOTION_MASK|gtk.gdk.BUTTON_PRESS_MASK|gtk.gdk.BUTTON_RELEASE_MASK)
| The Following User Says Thank You to daperl For This Useful Post: | ||
|
|
2009-07-10
, 17:32
|
|
|
Posts: 2,427 |
Thanked: 2,986 times |
Joined on Dec 2007
|
#8
|
Maybe too late, but you may need to add the image to EventBox and then add the EventBox to container.
|
|
2009-07-10
, 20:46
|
|
Posts: 146 |
Thanked: 15 times |
Joined on Oct 2008
|
#9
|
this is from panucci, a media player that uses the directional for playback control.
[...]
|
|
2009-07-10
, 23:51
|
|
|
Posts: 2,427 |
Thanked: 2,986 times |
Joined on Dec 2007
|
#10
|
...
window = gtk.Window()
window.connect("key-press-event", on_key_press)
...
def on_key_press(widget, event, *args):
returnValue = False
....
if event.keyval == gtk.keysyms.<DPAD_LEFT> or\
event.keyval == gtk.keysyms.<DPAD_RIGHT> or\
event.keyval == gtk.keysyms.<DPAD_UP> or\
event.keyval == gtk.keysyms.<DPAD_DOWN>:
...
returnValue = True
...
return returnValue
...
I am making an application for my N800 that has a small image viewer inside, and I want the user to be able to scroll the image with the finger.
Any link/indication about how to do that would be highly appreciated!
Thanks!
L.