| 305 | } |
| 306 | |
| 307 | static EditCommand ToEditCommand(KeyCode key, const InputManager& input) |
| 308 | { |
| 309 | #if MYGUI_PLATFORM == MYGUI_PLATFORM_LINUX || MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32 |
| 310 | switch (key.getValue()) |
| 311 | { |
| 312 | case KeyCode::Escape: return EditCommand::LoseFocus; |
| 313 | case KeyCode::Backspace: return EditCommand::ErasePrevious; |
| 314 | case KeyCode::Delete: return input.isShiftPressed() ? EditCommand::Cut : EditCommand::EraseNext; |
| 315 | case KeyCode::Insert: |
| 316 | return input.isShiftPressed() ? EditCommand::Paste |
| 317 | : (input.isControlPressed() ? EditCommand::Copy : EditCommand::Unknown); |
| 318 | case KeyCode::Return: |
| 319 | case KeyCode::NumpadEnter: return input.isControlPressed() ? EditCommand::AcceptEntry : EditCommand::NewLine; |
| 320 | case KeyCode::ArrowLeft: return input.isControlPressed() ? EditCommand::MoveLeftWord : EditCommand::MoveLeft; |
| 321 | case KeyCode::ArrowRight: return input.isControlPressed() ? EditCommand::MoveRightWord : EditCommand::MoveRight; |
| 322 | case KeyCode::ArrowUp: return EditCommand::MoveUp; |
| 323 | case KeyCode::ArrowDown: return EditCommand::MoveDown; |
| 324 | case KeyCode::Home: |
| 325 | return input.isControlPressed() ? EditCommand::MoveTextBeginning : EditCommand::MoveLineBeginning; |
| 326 | case KeyCode::End: return input.isControlPressed() ? EditCommand::MoveTextEnd : EditCommand::MoveLineEnd; |
| 327 | case KeyCode::PageUp: return EditCommand::MovePageUp; |
| 328 | case KeyCode::PageDown: return EditCommand::MovePageDown; |
| 329 | } |
| 330 | if (input.isControlPressed()) |
| 331 | { |
| 332 | switch (key.getValue()) |
| 333 | { |
| 334 | case KeyCode::C: return EditCommand::Copy; |
| 335 | case KeyCode::V: return EditCommand::Paste; |
| 336 | case KeyCode::X: return EditCommand::Cut; |
| 337 | case KeyCode::Z: return EditCommand::Undo; |
| 338 | case KeyCode::Y: return EditCommand::Redo; |
| 339 | case KeyCode::A: return EditCommand::SelectAll; |
| 340 | } |
| 341 | } |
| 342 | #elif MYGUI_PLATFORM == MYGUI_PLATFORM_APPLE |
| 343 | switch (key.getValue()) |
| 344 | { |
| 345 | case KeyCode::Escape: return EditCommand::LoseFocus; |
| 346 | case KeyCode::Backspace: return EditCommand::ErasePrevious; |
| 347 | case KeyCode::Delete: return EditCommand::EraseNext; |
| 348 | case KeyCode::Return: |
| 349 | case KeyCode::NumpadEnter: return input.isMetaPressed() ? EditCommand::AcceptEntry : EditCommand::NewLine; |
| 350 | case KeyCode::ArrowLeft: |
| 351 | { |
| 352 | if (input.isAltPressed()) |
| 353 | return EditCommand::MoveLeftWord; |
| 354 | if (input.isMetaPressed() || input.isControlPressed()) |
| 355 | return EditCommand::MoveLineBeginning; |
| 356 | return EditCommand::MoveLeft; |
| 357 | } |
| 358 | case KeyCode::ArrowRight: |
| 359 | { |
| 360 | if (input.isAltPressed()) |
| 361 | return EditCommand::MoveRightWord; |
| 362 | if (input.isMetaPressed() || input.isControlPressed()) |
| 363 | return EditCommand::MoveLineEnd; |
| 364 | return EditCommand::MoveRight; |
no test coverage detected