Macro Mouse Cross/fr: Difference between revisions

From FreeCAD Documentation
(Updating to match new version of source page)
(Created page with "{{Macro/fr|Icon=Text-x-python|Name=Macro_Mouse_Cross||Name/fr=Macro_Mouse_Cross|Description=Cette macro change la forme de la souris en une croix de précision.|Shortcut="C" "...")
Line 1: Line 1:
{{Macro|Icon=Text-x-python|Name=Macro_Mouse_Cross|Description=This macro turns the arrow of the mouse in a precision cross.|Shortcut="C" "A" |Author=Mario52}}
{{Macro/fr|Icon=Text-x-python|Name=Macro_Mouse_Cross||Name/fr=Macro_Mouse_Cross|Description=Cette macro change la forme de la souris en une croix de précision.|Shortcut="C" "A" |Author=Mario52}}


==Description==
==Description==

Revision as of 22:22, 2 February 2014

File:Text-x-python Macro_Mouse_Cross

Description
Cette macro change la forme de la souris en une croix de précision.

Auteur: Mario52
Auteur
Mario52
Téléchargement
None
Liens
Version Macro
1.0
Dernière modification
None
Version(s) FreeCAD
None
Raccourci clavier
"C" "A"
Voir aussi
None

Description

This small macro turns the arrow of the mouse in a precision cross.
Small example of using the class ViewObserver() and the use of the keyboard with SoKeyboardEvent

Macro_Mouse_Cross

How to use

  1. Press the C button to activate the cross.
  2. Press the A button to activate the arrow.

Script

Macro_Mouse_Cross.FCMacro

# -*- coding: utf-8 -*-
# Macro_Mouse_Cross mouse cursor to cross or arrow
from PyQt4 import QtCore, QtGui
class ViewObserver:
   def logPosition(self, info):
       self.pos = info["Key"]
       if (self.pos.upper() == "C"):
           # change the cursor cross ( + )
           QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.CrossCursor))
       elif (self.pos.upper() == "A"):
           # change the cursor Arrow
           QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor))

v=Gui.activeDocument().activeView()
o = ViewObserver()
c = v.addEventCallback("SoKeyboardEvent",o.logPosition)

Cursors that can be used

ArrowCursor, UpArrowCursor, CrossCursor, WaitCursor, IBeamCursor, SizeVerCursor, SizeHorCursor SizeBDiagCursor, SizeFDiagCursor, SizeAllCursor, BlankCursor, SplitVCursor, SplitHCursor PointingHandCursor, ForbiddenCursor, OpenHandCursor, ClosedHandCursor, WhatsThisCursor, BusyCursor, BitmapCursor

Limitation

The cursor can change appearance depending on the used Workbench, he must repeat the operation.
The cursor can be subtituer to the other sliders (ex: expansion of a window, corner...).
The rest resident macro.