• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

onEscape for miniWindows

4drik

Advanced OT User
Joined
Jun 30, 2014
Messages
254
Reaction score
202
I tried to do onEscape (close window by key - "Escape") for miniWindows.
Currently it only works for MainWindows so I wanted to extend it.

In corelib/ui/uiwindow is
Lua:
function UIWindow:onKeyDown(keyCode, keyboardModifiers)
  if keyboardModifiers == KeyboardNoModifier then
    if keyCode == KeyEnter then
      signalcall(self.onEnter, self)
    elseif keyCode == KeyEscape then
      signalcall(self.onEscape, self)
    end
  end
end

so I thought it was enough to edit it and put to uiminiwindow something like that
Lua:
function UIMiniWindow:onKeyDown(keyCode, keyboardModifiers)
  if keyboardModifiers == KeyboardNoModifier then
    if keyCode == KeyEscape then
      signalcall(self.onEscape, self)
    end
  end
end

but no effect so I don't have more ideas.
 
You need to add there onFocusChange function. To create func you need to add setAutoFocusPolicy
Lua:
miniwindow:setAutoFocusPolicy(AutoFocusFirst)
And in styles make miniwindow focusable, by default it is on false.
Note: You need to make your miniwindows focusable on open, also you won't be able msging on chat until you press on it.
 
I understand, thanks.
I see I should remove also onDrop function because when it's fitted to side panel - it's not responding too.

Well, I think I will resign of this addition.
 
Back
Top