Browse Source

Merge pull request #464 from engor/develop

Added ability to get Key by its name.
Mark Sibly 6 years ago
parent
commit
a622efaa78
2 changed files with 22 additions and 2 deletions
  1. 12 0
      modules/mojo/input/keyboard.monkey2
  2. 10 2
      modules/mojox/dockingview.monkey2

+ 12 - 0
modules/mojo/input/keyboard.monkey2

@@ -56,6 +56,18 @@ Class KeyboardDevice
 		Return _names[key]
 		Return _names[key]
 	End
 	End
 	
 	
+	#rem monkeydoc Gets the key by a given name.
+	#end
+	Method KeyFromName:Key( name:String )
+		
+		For Local i:=0 Until _names.Length
+			If _names[i]=name
+				Return Cast<Key>( i )
+			Endif
+		Next
+		Return Key.None
+	End
+	
 	#rem monkeydoc Translates a key to/from a raw key.
 	#rem monkeydoc Translates a key to/from a raw key.
 	
 	
 	If `key` is a raw key, returns the corresponding virtual key.
 	If `key` is a raw key, returns the corresponding virtual key.

+ 10 - 2
modules/mojox/dockingview.monkey2

@@ -7,8 +7,9 @@ Class DockKnob Extends View
 
 
 	Field Dragged:Void( v:Vec2i )
 	Field Dragged:Void( v:Vec2i )
 
 
-	Method New()
+	Method New( vertical:Bool )
 		Style=GetStyle( "DockKnob" )
 		Style=GetStyle( "DockKnob" )
+		_vertical=vertical
 	End
 	End
 	
 	
 	Protected
 	Protected
@@ -28,8 +29,11 @@ Class DockKnob Extends View
 			_drag=False
 			_drag=False
 		Case EventType.MouseEnter
 		Case EventType.MouseEnter
 			_hover=True
 			_hover=True
+			_storedCursor=Mouse.Cursor
+			Mouse.Cursor=_vertical ? MouseCursor.SizeWE Else MouseCursor.SizeNS
 		Case EventType.MouseLeave
 		Case EventType.MouseLeave
 			_hover=False
 			_hover=False
+			Mouse.Cursor=_storedCursor
 		Case EventType.MouseMove
 		Case EventType.MouseMove
 			If _drag Dragged( event.Location-_org )
 			If _drag Dragged( event.Location-_org )
 		End
 		End
@@ -49,6 +53,8 @@ Class DockKnob Extends View
 	
 	
 	Field _drag:Bool
 	Field _drag:Bool
 	Field _hover:Bool
 	Field _hover:Bool
+	Field _storedCursor:MouseCursor
+	Field _vertical:Bool
 	
 	
 End
 End
 
 
@@ -78,7 +84,9 @@ Class DockedView Extends View
 		
 		
 		If _sizeMode=SizeMode.Absolute And _resizable
 		If _sizeMode=SizeMode.Absolute And _resizable
 		
 		
-			_knob=New DockKnob
+			Local vertical:=(location="left" Or location="right")
+			
+			_knob=New DockKnob( vertical )
 			
 			
 			_knob.Dragged=Lambda( v:Vec2i )
 			_knob.Dragged=Lambda( v:Vec2i )