QScintilla/Editor.py

changeset 4290
5d4f4230a5ed
parent 4288
1c9c1c12111a
child 4292
9dfee1559826
equal deleted inserted replaced
4289:6c1ab651c9ce 4290:5d4f4230a5ed
31 from .QsciScintillaCompat import QsciScintillaCompat, QSCINTILLA_VERSION 31 from .QsciScintillaCompat import QsciScintillaCompat, QSCINTILLA_VERSION
32 from .EditorMarkerMap import EditorMarkerMap 32 from .EditorMarkerMap import EditorMarkerMap
33 33
34 import Preferences 34 import Preferences
35 import Utilities 35 import Utilities
36 from Utilities import MouseUtilities
36 37
37 import UI.PixmapCache 38 import UI.PixmapCache
38 39
39 EditorAutoCompletionListID = 1 40 EditorAutoCompletionListID = 1
40 TemplateCompletionListID = 2 41 TemplateCompletionListID = 2
375 376
376 # set the mouse click handlers (fired on mouse release) 377 # set the mouse click handlers (fired on mouse release)
377 self.__mouseClickHandlers = {} 378 self.__mouseClickHandlers = {}
378 # dictionary with tuple of keyboard modifier and mouse button as key 379 # dictionary with tuple of keyboard modifier and mouse button as key
379 # and tuple of plug-in name and function as value 380 # and tuple of plug-in name and function as value
380 self.__modifier2String = {
381 Qt.ShiftModifier: self.tr("Shift"),
382 Qt.ControlModifier: self.tr("Ctrl"),
383 Qt.AltModifier: self.tr("Alt"),
384 Qt.MetaModifier: self.tr("Meta"),
385 }
386 self.__button2String = {
387 Qt.LeftButton: self.tr("Left Button"),
388 Qt.RightButton: self.tr("Right Button"),
389 Qt.MidButton: self.tr("Middle Button"),
390 Qt.XButton1: self.tr("X Button 1"),
391 Qt.XButton2: self.tr("X Button 2"),
392 }
393 381
394 sh = self.sizeHint() 382 sh = self.sizeHint()
395 if sh.height() < 300: 383 if sh.height() < 300:
396 sh.setHeight(300) 384 sh.setHeight(300)
397 self.resize(sh) 385 self.resize(sh)
7583 7571
7584 ####################################################################### 7572 #######################################################################
7585 ## Mouse click handler related methods 7573 ## Mouse click handler related methods
7586 ####################################################################### 7574 #######################################################################
7587 7575
7588 def __mouseClickToString(self, modifiers, button):
7589 """
7590 Private method to generate a display string for the given modifiers
7591 and button combination.
7592
7593 @param modifiers keyboard modifiers of the handler
7594 @type Qt.KeyboardModifiers
7595 @param button mouse button of the handler
7596 @type Qt.MouseButton
7597 @return display string
7598 @rtype str
7599 """
7600 parts = []
7601 for mod in sorted(self.__modifier2String.keys()):
7602 if modifiers & mod:
7603 parts.append(self.__modifier2String[mod])
7604 parts.append(self.__button2String[button])
7605 return "+".join(parts)
7606
7607 def mouseReleaseEvent(self, evt): 7576 def mouseReleaseEvent(self, evt):
7608 """ 7577 """
7609 Protected method calling a registered mouse click handler function. 7578 Protected method calling a registered mouse click handler function.
7610 7579
7611 @param evt event object 7580 @param evt event object
7645 self, 7614 self,
7646 self.tr("Register Mouse Click Handler"), 7615 self.tr("Register Mouse Click Handler"),
7647 self.tr("""A mouse click handler for "{0}" was already""" 7616 self.tr("""A mouse click handler for "{0}" was already"""
7648 """ registered by "{1}". Aborting request by""" 7617 """ registered by "{1}". Aborting request by"""
7649 """ "{2}"...""").format( 7618 """ "{2}"...""").format(
7650 self.__mouseClickToString(modifiers, button), 7619 MouseUtilities.MouseButtonModifier2String(
7620 modifiers, button),
7651 self.__mouseClickHandlers[key][0], 7621 self.__mouseClickHandlers[key][0],
7652 name)) 7622 name))
7653 return False 7623 return False
7654 7624
7655 self.__mouseClickHandlers[key] = (name, function) 7625 self.__mouseClickHandlers[key] = (name, function)

eric ide

mercurial