Перейти к содержанию

Дайджесты за январь-февраль

Обновления гайдов и аддонов

Январь Февраль

Мониторинг серверов и редактор аддонов

Представляем вам две легенды. То, о чем можно было только мечтать, стало реальностью.

Мониторинг серверов Редактор аддонов

Подсказки из игры на вашем сайте

Теперь вы можете отображать сведения о внутриигровых элементах простым наведением курсора мыши.

Подробнее

Апдейтер аддонов

Представляем вам программу для автообновления аддонов и делимся подробностями.

Подробнее Скачать

How to close addon panel with ESC key?


cristimirt

Рекомендуемые сообщения

Sorry for writing in English, but I don't know Russian.
Also, I'm sorry if this question was asked and answered already, but it's hard for me to search the forum without know Russian.

I'm trying to close the panel of my addon by using the ESC key. I know of two ways to bind this key to a function, but each has a drawback.

  • One is to use 'ReactionEsc' in a WidgetEditLine (like it's done in BuildManager). This works but it requires to have a WidgetEditLine in focus, which I don't like, because I can't use it to cancel actions (PicCastbar has this problem)
  • The other one is to use 'bindSections' in a WidgetForm. I can bind the 'esc_pressed' action to a function using common.RegisterReactionHandler. This works without the need to have specialized widgets, but it introduces an annoyance : it also opens the Escape Menu

By looking a the lua code of the 1.0 addons, I can see that they use a kind of manager that keeps track of what widgets are visible and their order, so when you press the ESC key, the correct one closes, and the Menu only shows if there are no other widgets to hide. But of course, user addons don't have access to this, so we can't add our own widgets to this list.

I've found a quick hack that allows me to close my panel without triggering the Escape Menu, bit I don't like using it. The idea is to disable the EscMenu addon when I open my addon panel, and then enable it again right after I close my panel. This works ok for when you know your panel is not visible for too long and you're careful to always enable it back, but it might cause unforseen problems.

So my question is : Is there a proper way to close addon panels by pressing the escape key, without opening the Escape Menu?
 

PS: You can reply in russian, I will use Google Translate. Thank you!

Ссылка на комментарий
Поделиться на другие сайты

 This addon allows to close it with esc, maybe it will help.

Ссылка на комментарий
Поделиться на другие сайты

1 hour ago, самолет/Eksperyment said:

 This addon allows to close it with esc, maybe it will help.

Yeah, BuildManager. I looked at it, and it's where I found out about using WidgetEditLine. But this method works only when you have at least an input field in your window

Ссылка на комментарий
Поделиться на другие сайты

  • 2 недели спустя...

A "hack" that you can try is to put your addon as a child of EscMenu

stateMainForm:EscMenu:AddChild(mainForm)

i don't know if it will work, but i expect this to work like the other panels in the EscMenu (like video settings, etc.)

Ссылка на комментарий
Поделиться на другие сайты

Гость
Ответить в этой теме...

×   Вставлено с форматированием.   Восстановить форматирование

  Разрешено использовать не более 75 эмодзи.

×   Ваша ссылка была автоматически встроена.   Отображать как обычную ссылку

×   Ваш предыдущий контент был восстановлен.   Очистить редактор

×   Вы не можете вставлять изображения напрямую. Загружайте или вставляйте изображения по ссылке.

×
×
  • Создать...

Важная информация

Пользуясь сайтом, вы принимаете Условия использования