orca r4270 - branches/phase2/src/orca



Author: wwalker
Date: Tue Sep 30 00:05:27 2008
New Revision: 4270
URL: http://svn.gnome.org/viewvc/orca?rev=4270&view=rev

Log:
Add event_synthesizer.py.


Added:
   branches/phase2/src/orca/event_synthesizer.py   (contents, props changed)
Modified:
   branches/phase2/src/orca/Makefile.am

Modified: branches/phase2/src/orca/Makefile.am
==============================================================================
--- branches/phase2/src/orca/Makefile.am	(original)
+++ branches/phase2/src/orca/Makefile.am	Tue Sep 30 00:05:27 2008
@@ -7,6 +7,7 @@
 
 orca_python_PYTHON = \
 	__init__.py \
+	event_synthesizer.py \
 	input_binding.py \
 	input_event.py \
 	orca_i18n.py \

Added: branches/phase2/src/orca/event_synthesizer.py
==============================================================================
--- (empty file)
+++ branches/phase2/src/orca/event_synthesizer.py	Tue Sep 30 00:05:27 2008
@@ -0,0 +1,83 @@
+# Orca
+#
+# Copyright 2005-2008 Sun Microsystems Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Library General Public License for more details.
+#
+# You should have received a copy of the GNU Library General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., Franklin Street, Fifth Floor,
+# Boston MA  02110-1301 USA.
+
+"""Provides support for synthesizing keyboard and mouse events."""
+
+__id__        = "$Id$"
+__version__   = "$Revision$"
+__date__      = "$Date$"
+__copyright__ = "Copyright (c) 2005-2008 Sun Microsystems Inc."
+__license__   = "LGPL"
+
+import pyatspi
+
+def generateMouseEvent(x, y, eventName):
+    """Synthesize a mouse event at a specific screen coordinate.  Most
+    AT clients should use the #AccessibleAction interface when tempted
+    to generate mouse events, rather than this method.
+
+    Event names: b1p = button 1 press; b2r = button 2 release;
+                 b3c = button 3 click; b2d = button 2 double-click;
+                 abs = absolute motion; rel = relative motion.
+
+    Arguments:
+    - x: the x screen coordinate
+    - y: the y screen coordinate
+    - eventName: the event name string (as described above)
+    """
+    pyatspi.Registry.generateMouseEvent(x, y, eventName)
+
+def clickAccessible(accessible, button):
+    """Performs a button click on the given Accessible.
+
+    Arguments:
+    - accessible: the Accessible
+    - button: an integer representing the mouse button number
+    """
+    extents = accessible.queryComponent().getExtents(pyatspi.DESKTOP_COORDS)
+    x = extents.x + extents.width/2
+    y = extents.y + extents.height/2
+    generateMouseEvent(x, y, "b%dc" % button)
+
+def clickPoint(x, y, button):
+    """Performs a button click on the given point.
+
+    Arguments:
+    - x, y: the point
+    - button: an integer representing the mouse button number
+    """
+    generateMouseEvent(x, y, "b%dc" % button)
+
+def generateKeyboardEvent(keycode, keystring, eventType):
+    """Generates a keyboard event.
+
+    Arguments:
+    - keycode: a long integer indicating the keycode or keysym of the
+      key event being synthesized.
+    - keystring: an (optional) UTF-8 string which, if keyval is NULL,
+      indicates a 'composed' keyboard input string which is being
+      synthesized; this type of keyboard event synthesis does not
+      emulate hardware keypresses but injects the string as though a
+      composing input method (such as XIM) were used.
+    - eventType: an AccessibleKeySynthType flag indicating whether
+      keyval is to be interpreted as a keysym rather than a keycode
+      (pyatspi.KEY_SYM), or whether to synthesize KEY_PRESS,
+      KEY_RELEASE, or both (KEY_PRESSRELEASE).
+    """
+    pyatspi.Registry.generateKeyboardEvent(keycode, keystring, eventType)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]