You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been trying to handle the 'ESC' key in a menu I'm working on, but I've been having trouble. I don't know if I'm missing something in the documentation, but while exploring the code, I found a way to achieve this with some changes.
Here's the modified code snippet from php-school/cli-menu/src/CliMenu.php:300-321:
switch ($char->getControl()) {
case InputCharacter::UP:
case InputCharacter::DOWN:
$this->moveSelectionVertically($char->getControl());
$this->draw();
break;
case InputCharacter::LEFT:
case InputCharacter::RIGHT:
$this->moveSelectionHorizontally($char->getControl());
$this->draw();
break;
case InputCharacter::ENTER:
$this->executeCurrentItem();
break;
default:
$controlChar = $char->getControl();
if (isset($this->customControlMappings[$controlChar])) {
$this->customControlMappings[$controlChar]($this);
}
break;
}
With the 'default' case and by using addCustomControlMapping('ESC', $callable), I was able to handle the 'ESC' key effectively.
I believe this change could be useful. Should I open a PR for this, or do you think it might break something else?
Thanks!
The text was updated successfully, but these errors were encountered:
Hello everyone,
I've been trying to handle the 'ESC' key in a menu I'm working on, but I've been having trouble. I don't know if I'm missing something in the documentation, but while exploring the code, I found a way to achieve this with some changes.
Here's the modified code snippet from php-school/cli-menu/src/CliMenu.php:300-321:
With the 'default' case and by using
addCustomControlMapping('ESC', $callable)
, I was able to handle the 'ESC' key effectively.I believe this change could be useful. Should I open a PR for this, or do you think it might break something else?
Thanks!
The text was updated successfully, but these errors were encountered: