2
0
Эх сурвалжийг харах

Added support for keypad nav.

Mark Sibly 8 жил өмнө
parent
commit
9a9d257463

+ 48 - 57
modules/mojox/textview.monkey2

@@ -880,7 +880,7 @@ Class TextView Extends ScrollableView
 		
 	End
 	
-	Method OnKeyDown:Bool( key:Key,modifiers:Modifier=Null )
+	Method OnKeyDown:Bool( key:Key,modifiers:Modifier )
 	
 		Select key
 		Case Key.Backspace
@@ -947,7 +947,6 @@ Class TextView Extends ScrollableView
 				If go
 					ReplaceText( lines.Join( "" ) )
 					SelectText( _doc.StartOfLine( min ),_doc.StartOfLine( max ) )
-					Return False					
 				Endif
 					
 			Endif
@@ -1018,16 +1017,17 @@ Class TextView Extends ScrollableView
 			
 			Local n:=VisibleRect.Height/_charh-1
 			MoveLine( n )
-		
+			
 		Default
-
+		
 			Return False
+		
 		End
 		
 		Return True
 	End
 	
-	Method OnControlKeyDown:bool( key:Key,modifiers:Modifier=Null ) Virtual
+	Method OnControlKeyDown:Bool( key:Key,modifiers:Modifier ) Virtual
 
 		Select key
 		Case Key.A
@@ -1045,13 +1045,10 @@ Class TextView Extends ScrollableView
 		Case Key.Home
 			_cursor=0
 			UpdateCursor()
-			Return True
 		Case Key.KeyEnd
 			_cursor=_doc.TextLength
 			UpdateCursor()
-			Return True
 		Case Key.Left
-		
 			If _anchor<>_cursor And Not (modifiers & Modifier.Shift)
 				_cursor=Min( _anchor,_cursor )
 			Endif
@@ -1066,10 +1063,7 @@ Class TextView Extends ScrollableView
 			
 			_cursor=FindWord( Max( _cursor-1,0 ),term )
 			UpdateCursor()
-			Return True
-
 		Case Key.Right
-		
 			If _anchor<>_cursor And Not (modifiers & Modifier.Shift)
 				_cursor=Max( _anchor,_cursor )
 			Endif
@@ -1085,10 +1079,11 @@ Class TextView Extends ScrollableView
 			Wend
 			
 			UpdateCursor()
-			Return True
+		Default
+			Return false
 		End
 		
-		Return False
+		Return True
 	End
 	
 	Method OnKeyEvent( event:KeyEvent ) Override
@@ -1113,49 +1108,66 @@ Class TextView Extends ScrollableView
 		
 		Case EventType.KeyDown,EventType.KeyRepeat
 		
+			Local key:=event.Key
+			Local modifiers:=event.Modifiers
+			
+			'map keypad nav keys...
+			If Not (modifiers & Modifier.NumLock)
+				Select key
+				Case Key.Keypad1 key=Key.KeyEnd
+				Case Key.Keypad2 key=Key.Down
+				Case Key.Keypad3 key=Key.PageDown
+				Case Key.Keypad4 key=Key.Left
+				Case Key.Keypad6 key=Key.Right
+				Case Key.Keypad7 key=Key.Home
+				Case Key.Keypad8 key=Key.Up
+				Case Key.Keypad9 key=Key.PageUp
+				Case Key.Keypad0 key=Key.Insert
+				End
+			Endif
+			
+			Local r:=False
+			
 			If _macosMode
 			
-				If event.Modifiers & Modifier.Gui
+				If modifiers & Modifier.Gui
 				
-					Select event.Key
-					Case Key.Home,Key.KeyEnd
-					Default
-						If Not OnControlKeyDown( event.Key,event.Modifiers ) Return
+					Select key
+					Case Key.A,Key.X,Key.C,Key.V,Key.Z,Key.Y,Key.Left,Key.Right
+						r=OnControlKeyDown( key,modifiers )
 					End
-					
-				Else If event.Modifiers & Modifier.Control
 				
-					Select event.Key
+				Else If modifiers & Modifier.Control
+				
+					Select key
 					Case Key.A
-						OnKeyDown( Key.Home )
+						r=OnKeyDown( Key.Home,modifiers )
 					Case Key.E
-						OnKeyDown( Key.KeyEnd )
+						r=OnKeyDown( Key.KeyEnd,modifiers )
 					End
 					
 				Else
-
-					Select event.Key
-					Case Key.Home
-						OnControlKeyDown( Key.Home )
-					Case Key.KeyEnd
-						OnControlKeyDown( Key.KeyEnd )
+				
+					Select key
+					Case Key.Home,Key.KeyEnd
+						r=OnControlKeyDown( key,modifiers )
 					Default
-						If Not OnKeyDown( event.Key,event.Modifiers ) Return
+						r=OnKeyDown( key,modifiers )
 					End
-
+				
 				Endif
-			
+				
 			Else
 			
-				If event.Modifiers & Modifier.Control
-					If Not OnControlKeyDown( event.Key,event.Modifiers ) Return
+				If modifiers & Modifier.Control
+					r=OnControlKeyDown( key,modifiers )
 				Else
-					If Not OnKeyDown( event.Key,event.Modifiers ) Return
+					r=OnKeyDown( key,modifiers )
 				Endif
 			
 			Endif
 			
-			If Not (event.Modifiers & Modifier.Shift) _anchor=_cursor
+			If r And Not (modifiers & Modifier.Shift) _anchor=_cursor
 			
 		Case EventType.KeyChar
 		
@@ -1208,27 +1220,6 @@ Class TextView Extends ScrollableView
 		
 			Return
 			
-		#rem			
-		Case EventType.MouseClick
-		
-			_cursor=CharAtPoint( event.Location )
-			
-			If Not (event.Modifiers & Modifier.Shift) _anchor=_cursor
-			
-			_dragging=True
-			
-			MakeKeyView()
-			
-			UpdateCursor()
-			
-		Case EventType.MouseDoubleClick
-		
-			Local term:=New Int[1]
-			Local start:=FindWord( CharAtPoint( event.Location ),term )
-			
-			SelectText( start,term[0] )
-		#end
-		
 		Case EventType.MouseUp
 		
 			_dragging=False