restore terminal, rework console
This commit is contained in:
parent
a3721b3a11
commit
c4b2dd18d6
2
TODO
2
TODO
|
@ -44,6 +44,8 @@
|
|||
[bart] padding
|
||||
[bart] review and make more error prone with more warnings
|
||||
[bart] a real working border and background property in otui
|
||||
[bart] merge states declared in inherited styles
|
||||
[bart] reapply anchor styles when adding new childs
|
||||
|
||||
== Client modules
|
||||
[bart] modules managment interface
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
MapEffects = {}
|
||||
|
||||
function MapEffects.init()
|
||||
--[[
|
||||
local box = createWidget('ComboBox')
|
||||
box:moveTo({x=100, y=8})
|
||||
box:addOption('Normal')
|
||||
box:addOption('Bloom')
|
||||
box:addOption('TV')
|
||||
--displayUI(box)
|
||||
displayUI(box)
|
||||
]]--
|
||||
end
|
||||
|
||||
function MapEffects.terminate()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Console = { }
|
||||
Terminal = { }
|
||||
|
||||
-- configs
|
||||
local LogColors = { [LogInfo] = 'white',
|
||||
|
@ -8,11 +8,12 @@ local MaxLogLines = 80
|
|||
local LabelHeight = 16
|
||||
|
||||
-- private variables
|
||||
local consoleWidget
|
||||
local terminalWidget
|
||||
local terminalButton
|
||||
local logLocked = false
|
||||
local commandEnv = newenv()
|
||||
local commandLineEdit
|
||||
local consoleBuffer
|
||||
local terminalBuffer
|
||||
local commandHistory = { }
|
||||
local currentHistoryIndex = 0
|
||||
|
||||
|
@ -81,12 +82,12 @@ local function completeCommand()
|
|||
end
|
||||
end
|
||||
|
||||
local function onKeyPress(widget, keyCode, keyText, keyboardModifiers)
|
||||
local function onCommandLineKeyPress(widget, keyCode, keyText, keyboardModifiers)
|
||||
if keyboardModifiers == KeyboardNoModifier then
|
||||
-- execute current command
|
||||
if keyCode == KeyReturn or keyCode == keyEnter then
|
||||
if keyCode == KeyReturn or keyCode == KeyEnter then
|
||||
local currentCommand = commandLineEdit:getText()
|
||||
Console.executeCommand(currentCommand)
|
||||
Terminal.executeCommand(currentCommand)
|
||||
commandLineEdit:clearText()
|
||||
return true
|
||||
-- navigate history up
|
||||
|
@ -114,46 +115,64 @@ local function onLog(level, message, time)
|
|||
if logLocked then return end
|
||||
|
||||
logLocked = true
|
||||
Console.addLine(message, LogColors[level])
|
||||
Terminal.addLine(message, LogColors[level])
|
||||
logLocked = false
|
||||
end
|
||||
|
||||
-- public functions
|
||||
function Console.init()
|
||||
consoleWidget = displayUI('console.otui', { visible = false })
|
||||
connect(consoleWidget, { onKeyPress = onKeyPress })
|
||||
function Terminal.init()
|
||||
terminalWidget = displayUI('terminal.otui')
|
||||
terminalWidget:setVisible(false)
|
||||
|
||||
commandLineEdit = consoleWidget:getChildById('commandLineEdit')
|
||||
consoleBuffer = consoleWidget:getChildById('consoleBuffer')
|
||||
terminalButton = TopMenu.addButton('terminalButton', 'Terminal', '/core_styles/icons/terminal.png', Terminal.show)
|
||||
|
||||
commandLineEdit = terminalWidget:getChildById('commandLineEdit')
|
||||
connect(commandLineEdit, { onKeyPress = onCommandLineKeyPress })
|
||||
|
||||
terminalBuffer = terminalWidget:getChildById('terminalBuffer')
|
||||
Logger.setOnLog(onLog)
|
||||
Logger.fireOldMessages()
|
||||
end
|
||||
|
||||
function Console.terminate()
|
||||
function Terminal.terminate()
|
||||
Logger.setOnLog(nil)
|
||||
consoleWidget:destroy()
|
||||
terminalButton:destroy()
|
||||
terminalButton = nil
|
||||
commandLineEdit = nil
|
||||
consoleWidget = nil
|
||||
terminalBuffer = nil
|
||||
terminalWidget:destroy()
|
||||
terminalWidget = nil
|
||||
commandEnv = nil
|
||||
end
|
||||
|
||||
function Console.addLine(text, color)
|
||||
function Terminal.show()
|
||||
terminalWidget:show()
|
||||
terminalWidget:lock()
|
||||
end
|
||||
|
||||
function Terminal.hide()
|
||||
terminalWidget:unlock()
|
||||
terminalWidget:hide()
|
||||
end
|
||||
|
||||
function Terminal.addLine(text, color)
|
||||
-- create new line label
|
||||
local numLines = consoleBuffer:getChildCount() + 1
|
||||
local label = createWidget('ConsoleLabel', consoleBuffer)
|
||||
label:setId('consoleLabel' .. numLines)
|
||||
local numLines = terminalBuffer:getChildCount() + 1
|
||||
local label = createWidget('TerminalLabel', terminalBuffer)
|
||||
label:setId('terminalLabel' .. numLines)
|
||||
label:setText(text)
|
||||
label:setForegroundColor(color)
|
||||
|
||||
-- delete old lines if needed
|
||||
if numLines > MaxLogLines then
|
||||
consoleBuffer:getChildByIndex(1):destroy()
|
||||
terminalBuffer:getChildByIndex(1):destroy()
|
||||
else
|
||||
consoleBuffer:setHeight(consoleBuffer:getHeight() + LabelHeight)
|
||||
consoleBuffer:updateParentLayout()
|
||||
terminalBuffer:setHeight(terminalBuffer:getHeight() + LabelHeight)
|
||||
terminalBuffer:updateParentLayout()
|
||||
end
|
||||
end
|
||||
|
||||
function Console.executeCommand(command)
|
||||
function Terminal.executeCommand(command)
|
||||
-- detect and convert commands with simple syntax
|
||||
local realCommand
|
||||
if commandEnv[command] then
|
||||
|
@ -173,7 +192,7 @@ function Console.executeCommand(command)
|
|||
table.insert(commandHistory, command)
|
||||
|
||||
-- add command line
|
||||
Console.addLine(">> " .. command, "#ffffff")
|
||||
Terminal.addLine(">> " .. command, "#ffffff")
|
||||
|
||||
-- load command buffer
|
||||
local func, err = loadstring(realCommand, "@")
|
||||
|
@ -196,4 +215,3 @@ function Console.executeCommand(command)
|
|||
Logger.log(LogError, 'command failed: ' .. ret)
|
||||
end
|
||||
end
|
||||
|
|
@ -1,17 +1,16 @@
|
|||
Module
|
||||
name: console
|
||||
description: Console for executing lua functions
|
||||
name: terminal
|
||||
description: Terminal for executing lua functions
|
||||
author: OTClient team
|
||||
website: https://github.com/edubart/otclient
|
||||
|
||||
// console can be loaded after core
|
||||
autoLoad: true
|
||||
autoLoadPriority: 1000
|
||||
|
||||
onLoad: |
|
||||
require 'console'
|
||||
require 'terminal'
|
||||
require 'commands'
|
||||
Console.init()
|
||||
Terminal.init()
|
||||
|
||||
onUnload: |
|
||||
Console.terminate()
|
||||
Terminal.terminate()
|
|
@ -1,15 +1,15 @@
|
|||
ConsoleLabel < UILabel
|
||||
TerminalLabel < UILabel
|
||||
font: terminus-14px-bold
|
||||
height: 16
|
||||
|
||||
RectPanel
|
||||
id: consolePanel
|
||||
id: terminalPanel
|
||||
background-color: #000000
|
||||
opacity: 216
|
||||
anchors.fill: parent
|
||||
|
||||
Panel
|
||||
id: consoleBuffer
|
||||
id: terminalBuffer
|
||||
layout: verticalBox
|
||||
focusable: false
|
||||
anchors.left: parent.left
|
|
@ -1,16 +1,20 @@
|
|||
About = {}
|
||||
|
||||
-- private variables
|
||||
local aboutWindow
|
||||
local aboutButton
|
||||
|
||||
-- public functions
|
||||
function About.create()
|
||||
function About.init()
|
||||
aboutButton = TopMenu.addRightButton('aboutButton', 'About', '/core_styles/icons/about.png', About.display)
|
||||
end
|
||||
|
||||
function About.display()
|
||||
aboutWindow = displayUI('about.otui', { locked = true })
|
||||
end
|
||||
|
||||
function About.destroy()
|
||||
aboutWindow:destroy()
|
||||
aboutWindow = nil
|
||||
function About.terminate()
|
||||
aboutButton:destroy()
|
||||
aboutButton = nil
|
||||
end
|
||||
|
||||
function About.openWebpage()
|
||||
|
|
|
@ -6,3 +6,7 @@ Module
|
|||
|
||||
onLoad: |
|
||||
require 'about'
|
||||
About.init()
|
||||
|
||||
onUnload:
|
||||
About.terminate()
|
|
@ -58,4 +58,4 @@ MainWindow
|
|||
anchors.top: parent.top
|
||||
margin-top: 191
|
||||
margin-left: 188
|
||||
@onClick: About.destroy()
|
||||
@onClick: self:getParent():destroy()
|
||||
|
|
|
@ -4,11 +4,11 @@ Background = { }
|
|||
local background
|
||||
|
||||
-- public functions
|
||||
function Background.create()
|
||||
function Background.init()
|
||||
background = displayUI('background.otui')
|
||||
end
|
||||
|
||||
function Background.destroy()
|
||||
function Background.terminate()
|
||||
background:destroy()
|
||||
background = nil
|
||||
end
|
||||
|
|
|
@ -6,8 +6,8 @@ Module
|
|||
|
||||
onLoad: |
|
||||
require 'background'
|
||||
Background.create()
|
||||
Background.init()
|
||||
|
||||
onUnload:
|
||||
Background.destroy()
|
||||
Background.terminate()
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@ local loadBox
|
|||
local enterGame
|
||||
local motdNumber
|
||||
local motdMessage
|
||||
local motdButton
|
||||
local enterGameButton
|
||||
|
||||
|
||||
-- private functions
|
||||
local function clearAccountFields()
|
||||
|
@ -25,7 +28,7 @@ end
|
|||
local function onMotd(protocol, motd)
|
||||
motdNumber = tonumber(motd:sub(0, motd:find("\n")))
|
||||
motdMessage = motd:sub(motd:find("\n") + 1, #motd)
|
||||
TopMenu.getButton('motdButton'):show()
|
||||
motdButton:show()
|
||||
end
|
||||
|
||||
local function onCharacterList(protocol, characters, premDays)
|
||||
|
@ -50,7 +53,10 @@ local function onCharacterList(protocol, characters, premDays)
|
|||
end
|
||||
|
||||
-- public functions
|
||||
function EnterGame.create()
|
||||
function EnterGame.init()
|
||||
enterGameButton = TopMenu.addButton('enterGameButton', 'Login', '/core_styles/icons/login.png', EnterGame.openWindow)
|
||||
motdButton = TopMenu.addButton('motdButton', 'Message of the day', '/core_styles/icons/motd.png', EnterGame.displayMotd)
|
||||
motdButton:hide()
|
||||
enterGame = displayUI('entergame.otui')
|
||||
|
||||
local account = Settings.get('account')
|
||||
|
@ -72,9 +78,13 @@ function EnterGame.create()
|
|||
end
|
||||
end
|
||||
|
||||
function EnterGame.destroy()
|
||||
function EnterGame.terminate()
|
||||
enterGame:destroy()
|
||||
enterGame = nil
|
||||
enterGameButton:destroy()
|
||||
enterGameButton = nil
|
||||
motdButton:destroy()
|
||||
motdButton = nil
|
||||
end
|
||||
|
||||
function EnterGame.show()
|
||||
|
@ -86,6 +96,14 @@ function EnterGame.hide()
|
|||
enterGame:hide()
|
||||
end
|
||||
|
||||
function EnterGame.openWindow()
|
||||
if Game.isOnline() then
|
||||
CharacterList.show()
|
||||
elseif not CharacterList.isVisible() then
|
||||
EnterGame.show()
|
||||
end
|
||||
end
|
||||
|
||||
function EnterGame.doLogin()
|
||||
EnterGame.account = enterGame:getChildById('accountNameLineEdit'):getText()
|
||||
EnterGame.password = enterGame:getChildById('accountPasswordLineEdit'):getText()
|
||||
|
@ -111,5 +129,6 @@ function EnterGame.doLogin()
|
|||
end
|
||||
|
||||
function EnterGame.displayMotd()
|
||||
displayInfoBox("Message of the day", motdMessage)
|
||||
displayInfoBox('Message of the day', motdMessage)
|
||||
end
|
||||
|
||||
|
|
|
@ -7,9 +7,9 @@ Module
|
|||
onLoad: |
|
||||
require 'entergame'
|
||||
require 'characterlist'
|
||||
EnterGame.create()
|
||||
EnterGame.init()
|
||||
|
||||
onUnload:
|
||||
EnterGame.destroy()
|
||||
EnterGame.terminate()
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,16 @@
|
|||
Options = {}
|
||||
|
||||
local optionsButton
|
||||
|
||||
function Options.init()
|
||||
optionsButton = TopMenu.addButton('settingsButton', 'Options', '/core_styles/icons/settings.png', Options.show)
|
||||
Options.load()
|
||||
end
|
||||
|
||||
function Options.terminate()
|
||||
TopMenu.removeButton(optionsButton)
|
||||
end
|
||||
|
||||
function Options.load()
|
||||
local booleanOptions = { vsync = true,
|
||||
showfps = true,
|
||||
|
|
|
@ -6,5 +6,7 @@ Module
|
|||
|
||||
onLoad: |
|
||||
require 'options'
|
||||
Options.load()
|
||||
Options.init()
|
||||
|
||||
onUnload:
|
||||
Options.terminate()
|
|
@ -2,17 +2,74 @@ TopMenu = {}
|
|||
|
||||
-- private variables
|
||||
local topMenu
|
||||
local leftButtonsPanel
|
||||
local rightButtonsPanel
|
||||
|
||||
-- public functions
|
||||
function TopMenu.create()
|
||||
function TopMenu.init()
|
||||
topMenu = displayUI('topmenu.otui')
|
||||
leftButtonsPanel = topMenu:getChildById('leftButtonsPanel')
|
||||
rightButtonsPanel = topMenu:getChildById('rightButtonsPanel')
|
||||
|
||||
TopMenu.addRightButton('logoutButton', 'Logout', '/core_styles/icons/logout.png',
|
||||
function()
|
||||
if Game.isOnline() then
|
||||
Game.logout(false)
|
||||
else
|
||||
exit()
|
||||
end
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
function TopMenu.destroy()
|
||||
function TopMenu.terminate()
|
||||
leftButtonsPanel = nil
|
||||
rightButtonsPanel = nil
|
||||
topMenu:destroy()
|
||||
topMenu = nil
|
||||
end
|
||||
|
||||
function TopMenu.getButton(id)
|
||||
return topMenu:getChildById(id)
|
||||
function TopMenu.addButton(id, description, icon, callback, right)
|
||||
local panel
|
||||
local class
|
||||
if right then
|
||||
panel = rightButtonsPanel
|
||||
class = 'TopRightButton'
|
||||
else
|
||||
panel = leftButtonsPanel
|
||||
class = 'TopLeftButton'
|
||||
end
|
||||
|
||||
local button = createWidget(class, panel)
|
||||
button:setId(id)
|
||||
button:setTooltip(description)
|
||||
button:setIcon(resolvepath(icon, 2))
|
||||
button.onClick = callback
|
||||
return button
|
||||
end
|
||||
|
||||
function TopMenu.addLeftButton(id, description, icon, callback)
|
||||
return TopMenu.addButton(id, description, icon, callback, false)
|
||||
end
|
||||
|
||||
function TopMenu.addRightButton(id, description, icon, callback)
|
||||
return TopMenu.addButton(id, description, icon, callback, true)
|
||||
end
|
||||
|
||||
function TopMenu.removeButton(param)
|
||||
local button
|
||||
if type(param) == 'string' then
|
||||
button = TopMenu.getButton(param)
|
||||
else
|
||||
button = param
|
||||
end
|
||||
button:destroy()
|
||||
end
|
||||
|
||||
function TopMenu.getButton(id)
|
||||
return topMenu:recursiveGetChildById(id)
|
||||
end
|
||||
|
||||
function TopMenu:getLogoutButton(id)
|
||||
return TopMenu.getButton('logoutButton')
|
||||
end
|
||||
|
|
|
@ -6,7 +6,7 @@ Module
|
|||
|
||||
onLoad: |
|
||||
require 'topmenu'
|
||||
TopMenu.create()
|
||||
TopMenu.init()
|
||||
|
||||
onUnload: |
|
||||
TopMenu.destroy()
|
||||
TopMenu.terminate()
|
||||
|
|
|
@ -1,3 +1,52 @@
|
|||
TopButton < UIButton
|
||||
background-color: white
|
||||
size: 26 26
|
||||
text-translate: 0 0
|
||||
border-image:
|
||||
source: /core_styles/images/top_button.png
|
||||
clip: 0 0 26 26
|
||||
border: 3
|
||||
|
||||
$hover:
|
||||
border-image:
|
||||
source: /core_styles/images/top_button.png
|
||||
clip: 26 0 26 26
|
||||
border: 3
|
||||
|
||||
$pressed:
|
||||
text-translate: 1 1
|
||||
border-image:
|
||||
source: /core_styles/images/top_button.png
|
||||
clip: 52 0 26 26
|
||||
border: 3
|
||||
|
||||
$disabled:
|
||||
background-color: #ffffff66
|
||||
|
||||
TopLeftButton < TopButton
|
||||
$first:
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
margin-top: 4
|
||||
margin-left: 6
|
||||
|
||||
$!first:
|
||||
anchors.top: prev.top
|
||||
anchors.left: prev.right
|
||||
margin-left: 6
|
||||
|
||||
TopRightButton < TopButton
|
||||
$first:
|
||||
anchors.top: parent.top
|
||||
anchors.right: parent.right
|
||||
margin-top: 4
|
||||
margin-right: 6
|
||||
|
||||
$!first:
|
||||
anchors.top: prev.top
|
||||
anchors.right: prev.left
|
||||
margin-right: 6
|
||||
|
||||
TopPanel
|
||||
id: topMenu
|
||||
anchors.top: parent.top
|
||||
|
@ -5,63 +54,19 @@ TopPanel
|
|||
anchors.right: parent.right
|
||||
focusable: false
|
||||
|
||||
TopButton
|
||||
id: settingsButton
|
||||
Panel
|
||||
id: leftButtonsPanel
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
margin-top: 4
|
||||
margin-left: 6
|
||||
tooltip: Options
|
||||
icon: /core_styles/icons/settings.png
|
||||
@onClick: Options.show()
|
||||
anchors.right: next.left
|
||||
|
||||
|
||||
TopButton
|
||||
id: enterGameButton
|
||||
anchors.top: prev.top
|
||||
anchors.left: prev.right
|
||||
margin-left: 6
|
||||
tooltip: Enter game with a character
|
||||
icon: /core_styles/icons/login.png
|
||||
@onClick: |
|
||||
if Game.isOnline() then
|
||||
CharacterList.show()
|
||||
elseif not CharacterList.isVisible() then
|
||||
EnterGame.show()
|
||||
end
|
||||
|
||||
TopButton
|
||||
id: motdButton
|
||||
anchors.top: prev.top
|
||||
anchors.left: prev.right
|
||||
margin-left: 6
|
||||
tooltip: Message of the day
|
||||
icon: /core_styles/icons/motd.png
|
||||
visible: false
|
||||
@onClick: EnterGame.displayMotd()
|
||||
|
||||
TopButton
|
||||
Panel
|
||||
id: rightButtonsPanel
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.right: parent.right
|
||||
margin-top: 4
|
||||
margin-right: 6
|
||||
tooltip: Logout
|
||||
icon: /core_styles/icons/logout.png
|
||||
@onClick: |
|
||||
if Game.isOnline() then
|
||||
Game.logout(false)
|
||||
else
|
||||
exit()
|
||||
end
|
||||
|
||||
TopButton
|
||||
anchors.top: parent.top
|
||||
anchors.right: prev.left
|
||||
margin-top: 4
|
||||
margin-right: 6
|
||||
tooltip: About OTClient
|
||||
icon: /core_styles/icons/about.png
|
||||
@onClick: About.create()
|
||||
width: 60
|
||||
|
||||
FrameCounter
|
||||
id: frameCounter
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 459 B |
|
@ -24,28 +24,3 @@ Button < UIButton
|
|||
color: #f0ad4d88
|
||||
background-color: #ffffff88
|
||||
|
||||
TopButton < UIButton
|
||||
background-color: white
|
||||
size: 26 26
|
||||
text-translate: 0 0
|
||||
border-image:
|
||||
source: /core_styles/images/top_button.png
|
||||
clip: 0 0 26 26
|
||||
border: 3
|
||||
|
||||
$hover:
|
||||
border-image:
|
||||
source: /core_styles/images/top_button.png
|
||||
clip: 26 0 26 26
|
||||
border: 3
|
||||
|
||||
$pressed:
|
||||
text-translate: 1 1
|
||||
border-image:
|
||||
source: /core_styles/images/top_button.png
|
||||
clip: 52 0 26 26
|
||||
border: 3
|
||||
|
||||
$disabled:
|
||||
background-color: #ffffff66
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ public:
|
|||
|
||||
/// Returns the class name used in Lua
|
||||
virtual std::string getLuaObjectName() const {
|
||||
// this could later be cached for more performance
|
||||
// TODO: this could be cached for more performance
|
||||
return Fw::demangleName(typeid(*this).name());
|
||||
}
|
||||
|
||||
|
|
|
@ -95,6 +95,13 @@ void OTMLNode::addChild(const OTMLNodePtr& newChild)
|
|||
for(const OTMLNodePtr& node : m_children) {
|
||||
if(node->tag() == newChild->tag() && (node->isUnique() || newChild->isUnique())) {
|
||||
newChild->setUnique(true);
|
||||
|
||||
if(node->hasChildren() && newChild->hasChildren()) {
|
||||
OTMLNodePtr tmpNode = node->clone();
|
||||
tmpNode->merge(newChild);
|
||||
newChild->copy(tmpNode);
|
||||
}
|
||||
|
||||
replaceChild(node, newChild);
|
||||
|
||||
// remove any other child with the same tag
|
||||
|
@ -140,6 +147,18 @@ bool OTMLNode::replaceChild(const OTMLNodePtr& oldChild, const OTMLNodePtr& newC
|
|||
return false;
|
||||
}
|
||||
|
||||
void OTMLNode::copy(const OTMLNodePtr& node)
|
||||
{
|
||||
setTag(node->tag());
|
||||
setValue(node->value());
|
||||
setUnique(node->isUnique());
|
||||
setNull(node->isNull());
|
||||
setSource(node->source());
|
||||
clear();
|
||||
for(const OTMLNodePtr& child : node->m_children)
|
||||
addChild(child->clone());
|
||||
}
|
||||
|
||||
void OTMLNode::merge(const OTMLNodePtr& node)
|
||||
{
|
||||
for(const OTMLNodePtr& child : node->m_children)
|
||||
|
|
|
@ -63,6 +63,7 @@ public:
|
|||
void addChild(const OTMLNodePtr& newChild);
|
||||
bool removeChild(const OTMLNodePtr& oldChild);
|
||||
bool replaceChild(const OTMLNodePtr& oldChild, const OTMLNodePtr& newChild);
|
||||
void copy(const OTMLNodePtr& node);
|
||||
void merge(const OTMLNodePtr& node);
|
||||
void clear();
|
||||
|
||||
|
|
|
@ -411,6 +411,9 @@ void UILineEdit::onFocusChange(bool focused, Fw::FocusReason reason)
|
|||
|
||||
bool UILineEdit::onKeyPress(uchar keyCode, std::string keyText, int keyboardModifiers)
|
||||
{
|
||||
if(UIWidget::onKeyPress(keyCode, keyText, keyboardModifiers))
|
||||
return true;
|
||||
|
||||
if(keyCode == Fw::KeyDelete) // erase right character
|
||||
removeCharacter(true);
|
||||
else if(keyCode == Fw::KeyBackspace) // erase left character {
|
||||
|
@ -433,8 +436,7 @@ bool UILineEdit::onKeyPress(uchar keyCode, std::string keyText, int keyboardModi
|
|||
} else if(!keyText.empty() && (keyboardModifiers == Fw::KeyboardNoModifier || keyboardModifiers == Fw::KeyboardShiftModifier))
|
||||
appendText(keyText);
|
||||
else
|
||||
return UIWidget::onKeyPress(keyCode, keyText, keyboardModifiers);
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1116,8 +1116,12 @@ void UIWidget::onStyleApply(const std::string& styleName, const OTMLNodePtr& sty
|
|||
// anchors
|
||||
else if(boost::starts_with(node->tag(), "anchors.")) {
|
||||
UIWidgetPtr parent = getParent();
|
||||
if(!parent)
|
||||
if(!parent) {
|
||||
if(m_firstOnStyle)
|
||||
throw OTMLException(node, "cannot create anchor, there is no parent widget!");
|
||||
else
|
||||
continue;
|
||||
}
|
||||
|
||||
UIAnchorLayoutPtr anchorLayout = parent->getLayout()->asUIAnchorLayout();
|
||||
if(!anchorLayout)
|
||||
|
@ -1331,8 +1335,6 @@ void UIWidget::propagateOnMouseRelease(const Point& mousePos, Fw::MouseButton bu
|
|||
child->setPressed(false);
|
||||
}
|
||||
|
||||
// fire release events only when pressed
|
||||
if(isPressed())
|
||||
onMouseRelease(mousePos, button);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue