Macro Mouse Cross/cs: Difference between revisions

From FreeCAD Documentation
No edit summary
(Updating to match new version of source page)
Line 17: Line 17:
<syntaxhighlight>
<syntaxhighlight>
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
# Macro_Mouse_Cross mouse cursor to cross or arrow
# mouse cursor to Cross or Arrow + Grig
from PyQt4 import QtCore, QtGui
from PyQt4 import QtCore, QtGui
from pivy import coin
class ViewObserver:
class ViewObserver:
def logPosition(self, info):
def logPosition(self, info):
Line 28: Line 29:
# change the cursor Arrow
# change the cursor Arrow
QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor))
QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor))
elif (self.pos.upper() == "G"):

# "wmayer" http://forum.freecadweb.org/viewtopic.php?f=3&t=1065&hilit=cross#p8818
# Create Grid
grid=coin.SoType.fromName("SoDrawingGrid").createInstance()
Gui.ActiveDocument.ActiveView.getSceneGraph().addChild(grid)
v=Gui.activeDocument().activeView()
v=Gui.activeDocument().activeView()
o = ViewObserver()
o = ViewObserver()
c = v.addEventCallback("SoKeyboardEvent",o.logPosition)
c = v.addEventCallback("SoKeyboardEvent",o.logPosition)

</syntaxhighlight>
</syntaxhighlight>
===Kurzory, které mohou být používány===
===Kurzory, které mohou být používány===

Revision as of 03:58, 8 February 2014

File:Text-x-python Macro_Mouse_Cross

Description
Toto malé makro mění šipku kurzoru myši na jemný křížek.

Author: Mario52
Author
Mario52
Download
None
Links
Macro Version
1.0
Date last modified
None
FreeCAD Version(s)
None
Default shortcut
"C" "A"
See also
None

Popis

Toto malé makro mění šipku kurzoru myši na jemný křížek.
Malý příklad použití třídy ViewObserver() a použití klávesnice SoKeyboardEvent

Macro_Mouse_Cross

Použití

  1. Stiskněte klávesu C pro aktivaci křížku.
  2. Stiskněte klávesu A pro aktivaci šipky.

Skript

Macro_Mouse_Cross.FCMacro

# -*- coding: utf-8 -*-
# mouse cursor to Cross or Arrow + Grig 
from PyQt4 import QtCore, QtGui
from pivy import coin
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))
       elif (self.pos.upper() == "G"):
           # "wmayer" http://forum.freecadweb.org/viewtopic.php?f=3&t=1065&hilit=cross#p8818
           # Create Grid
           grid=coin.SoType.fromName("SoDrawingGrid").createInstance()
           Gui.ActiveDocument.ActiveView.getSceneGraph().addChild(grid)
v=Gui.activeDocument().activeView()
o = ViewObserver()
c = v.addEventCallback("SoKeyboardEvent",o.logPosition)

Kurzory, které mohou být používány

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

Omezení

Kurzor může měnit vzhled v závislosti na používané pracovní ploše, musí opakovat funkci.

The cursor can be subtitued to the other sliders (ex: expansion of a window, corner...).
The rest resident macro.