Changed how buttons are stored in press and release events
This commit is contained in:
		
							parent
							
								
									b816a4abf5
								
							
						
					
					
						commit
						1d71df180d
					
				| @ -42,7 +42,9 @@ func (backend *Backend) handleButtonPress ( | ||||
| 	event xevent.ButtonPressEvent, | ||||
| ) { | ||||
| 	buttonEvent := *event.ButtonPressEvent | ||||
| 	backend.channel <- stone.EventPress(buttonEvent.Detail) | ||||
| 	backend.channel <- stone.EventPress { | ||||
| 		Button: stone.Button(buttonEvent.Detail), | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func (backend *Backend) handleButtonRelease ( | ||||
| @ -50,7 +52,9 @@ func (backend *Backend) handleButtonRelease ( | ||||
| 	event xevent.ButtonReleaseEvent, | ||||
| ) { | ||||
| 	buttonEvent := *event.ButtonReleaseEvent | ||||
| 	backend.channel <- stone.EventRelease(buttonEvent.Detail) | ||||
| 	backend.channel <- stone.EventRelease { | ||||
| 		Button: stone.Button(buttonEvent.Detail), | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func (backend *Backend) handleKeyPress ( | ||||
| @ -59,7 +63,7 @@ func (backend *Backend) handleKeyPress ( | ||||
| ) { | ||||
| 	keyEvent := *event.KeyPressEvent | ||||
| 	button   := backend.keycodeToButton(keyEvent.Detail, keyEvent.State) | ||||
| 	backend.channel <- stone.EventPress(button) | ||||
| 	backend.channel <- stone.EventPress { Button: button } | ||||
| } | ||||
| 
 | ||||
| func (backend *Backend) handleKeyRelease ( | ||||
| @ -68,7 +72,7 @@ func (backend *Backend) handleKeyRelease ( | ||||
| ) { | ||||
| 	keyEvent := *event.KeyReleaseEvent | ||||
| 	button   := backend.keycodeToButton(keyEvent.Detail, keyEvent.State) | ||||
| 	backend.channel <- stone.EventRelease(button) | ||||
| 	backend.channel <- stone.EventRelease { Button: button } | ||||
| } | ||||
| 
 | ||||
| func (backend *Backend) handleMotionNotify ( | ||||
|  | ||||
							
								
								
									
										4
									
								
								event.go
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								event.go
									
									
									
									
									
								
							| @ -3,8 +3,8 @@ package stone | ||||
| type Event interface { } | ||||
| 
 | ||||
| type EventQuit      struct { } | ||||
| type EventPress     Button | ||||
| type EventRelease   Button | ||||
| type EventPress     struct { Button } | ||||
| type EventRelease   struct { Button } | ||||
| type EventResize    struct { } | ||||
| type EventMouseMove struct { | ||||
| 	X int | ||||
|  | ||||
| @ -38,16 +38,16 @@ func main () { | ||||
| 			os.Exit(0) | ||||
| 
 | ||||
| 		case stone.EventPress: | ||||
| 			event := event.(stone.EventPress) | ||||
| 			if stone.Button(event) == stone.MouseButtonLeft { | ||||
| 			button := event.(stone.EventPress).Button | ||||
| 			if button == stone.MouseButtonLeft { | ||||
| 				mousePressed = true | ||||
| 				application.SetRune(0, 0, '+') | ||||
| 				application.Draw() | ||||
| 			} | ||||
| 
 | ||||
| 		case stone.EventRelease: | ||||
| 			event := event.(stone.EventRelease) | ||||
| 			if stone.Button(event) == stone.MouseButtonLeft { | ||||
| 			button := event.(stone.EventRelease).Button | ||||
| 			if button == stone.MouseButtonLeft { | ||||
| 				mousePressed = false | ||||
| 				application.SetRune(0, 0, 0) | ||||
| 				application.Draw() | ||||
|  | ||||
| @ -38,7 +38,7 @@ func main () { | ||||
| 			os.Exit(0) | ||||
| 
 | ||||
| 		case stone.EventPress: | ||||
| 			button := stone.Button(event.(stone.EventPress)) | ||||
| 			button := event.(stone.EventPress).Button | ||||
| 			if button.Printable() { | ||||
| 				application.SetRune(caret, 0, rune(button)) | ||||
| 				caret ++ | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user