Browse Source

restore terminal, rework console

Eduardo Bart 9 years ago
parent
commit
c4b2dd18d6

+ 2
- 0
TODO View File

@@ -44,6 +44,8 @@
44 44
 [bart] padding
45 45
 [bart] review and make more error prone with more warnings
46 46
 [bart] a real working border and background property in otui
47
+[bart] merge states declared in inherited styles
48
+[bart] reapply anchor styles when adding new childs
47 49
 
48 50
 == Client modules
49 51
 [bart] modules managment interface

+ 3
- 1
modules/addon_mapeffects/mapeffects.lua View File

@@ -1,12 +1,14 @@
1 1
 MapEffects = {}
2 2
 
3 3
 function MapEffects.init()
4
+--[[
4 5
   local box = createWidget('ComboBox')
5 6
   box:moveTo({x=100, y=8})
6 7
   box:addOption('Normal')
7 8
   box:addOption('Bloom')
8 9
   box:addOption('TV')
9
-  --displayUI(box)
10
+  displayUI(box)
11
+  ]]--
10 12
 end
11 13
 
12 14
 function MapEffects.terminate()

modules/addon_console/commands.lua → modules/addon_terminal/commands.lua View File


modules/addon_console/console.lua → modules/addon_terminal/terminal.lua View File

@@ -1,4 +1,4 @@
1
-Console = { }
1
+Terminal = { }
2 2
 
3 3
 -- configs
4 4
 local LogColors = { [LogInfo] = 'white',
@@ -8,11 +8,12 @@ local MaxLogLines = 80
8 8
 local LabelHeight = 16
9 9
 
10 10
 -- private variables
11
-local consoleWidget
11
+local terminalWidget
12
+local terminalButton
12 13
 local logLocked = false
13 14
 local commandEnv = newenv()
14 15
 local commandLineEdit
15
-local consoleBuffer
16
+local terminalBuffer
16 17
 local commandHistory = { }
17 18
 local currentHistoryIndex = 0
18 19
 
@@ -81,12 +82,12 @@ local function completeCommand()
81 82
   end
82 83
 end
83 84
 
84
-local function onKeyPress(widget, keyCode, keyText, keyboardModifiers)
85
+local function onCommandLineKeyPress(widget, keyCode, keyText, keyboardModifiers)
85 86
   if keyboardModifiers == KeyboardNoModifier then
86 87
     -- execute current command
87
-    if keyCode == KeyReturn or keyCode == keyEnter then
88
+    if keyCode == KeyReturn or keyCode == KeyEnter then
88 89
       local currentCommand = commandLineEdit:getText()
89
-      Console.executeCommand(currentCommand)
90
+      Terminal.executeCommand(currentCommand)
90 91
       commandLineEdit:clearText()
91 92
       return true
92 93
     -- navigate history up
@@ -114,46 +115,64 @@ local function onLog(level, message, time)
114 115
   if logLocked then return end
115 116
 
116 117
   logLocked = true
117
-  Console.addLine(message, LogColors[level])
118
+  Terminal.addLine(message, LogColors[level])
118 119
   logLocked = false
119 120
 end
120 121
 
121 122
 -- public functions
122
-function Console.init()
123
-  consoleWidget = displayUI('console.otui', { visible = false })
124
-  connect(consoleWidget, { onKeyPress = onKeyPress })
123
+function Terminal.init()
124
+  terminalWidget = displayUI('terminal.otui')
125
+  terminalWidget:setVisible(false)
125 126
 
126
-  commandLineEdit = consoleWidget:getChildById('commandLineEdit')
127
-  consoleBuffer = consoleWidget:getChildById('consoleBuffer')
127
+  terminalButton = TopMenu.addButton('terminalButton', 'Terminal', '/core_styles/icons/terminal.png', Terminal.show)
128
+
129
+  commandLineEdit = terminalWidget:getChildById('commandLineEdit')
130
+  connect(commandLineEdit, { onKeyPress = onCommandLineKeyPress })
131
+
132
+  terminalBuffer = terminalWidget:getChildById('terminalBuffer')
128 133
   Logger.setOnLog(onLog)
129 134
   Logger.fireOldMessages()
130 135
 end
131 136
 
132
-function Console.terminate()
137
+function Terminal.terminate()
133 138
   Logger.setOnLog(nil)
134
-  consoleWidget:destroy()
139
+  terminalButton:destroy()
140
+  terminalButton = nil
135 141
   commandLineEdit = nil
136
-  consoleWidget = nil
142
+  terminalBuffer = nil
143
+  terminalWidget:destroy()
144
+  terminalWidget = nil
145
+  commandEnv = nil
146
+end
147
+
148
+function Terminal.show()
149
+  terminalWidget:show()
150
+  terminalWidget:lock()
137 151
 end
138 152
 
139
-function Console.addLine(text, color)
153
+function Terminal.hide()
154
+  terminalWidget:unlock()
155
+  terminalWidget:hide()
156
+end
157
+
158
+function Terminal.addLine(text, color)
140 159
   -- create new line label
141
-  local numLines = consoleBuffer:getChildCount() + 1
142
-  local label = createWidget('ConsoleLabel', consoleBuffer)
143
-  label:setId('consoleLabel' .. numLines)
160
+  local numLines = terminalBuffer:getChildCount() + 1
161
+  local label = createWidget('TerminalLabel', terminalBuffer)
162
+  label:setId('terminalLabel' .. numLines)
144 163
   label:setText(text)
145 164
   label:setForegroundColor(color)
146 165
 
147 166
   -- delete old lines if needed
148 167
   if numLines > MaxLogLines then
149
-    consoleBuffer:getChildByIndex(1):destroy()
168
+    terminalBuffer:getChildByIndex(1):destroy()
150 169
   else
151
-    consoleBuffer:setHeight(consoleBuffer:getHeight() + LabelHeight)
152
-    consoleBuffer:updateParentLayout()
170
+    terminalBuffer:setHeight(terminalBuffer:getHeight() + LabelHeight)
171
+    terminalBuffer:updateParentLayout()
153 172
   end
154 173
 end
155 174
 
156
-function Console.executeCommand(command)
175
+function Terminal.executeCommand(command)
157 176
   -- detect and convert commands with simple syntax
158 177
   local realCommand
159 178
   if commandEnv[command] then
@@ -173,7 +192,7 @@ function Console.executeCommand(command)
173 192
   table.insert(commandHistory, command)
174 193
 
175 194
   -- add command line
176
-  Console.addLine(">> " .. command, "#ffffff")
195
+  Terminal.addLine(">> " .. command, "#ffffff")
177 196
 
178 197
   -- load command buffer
179 198
   local func, err = loadstring(realCommand, "@")
@@ -196,4 +215,3 @@ function Console.executeCommand(command)
196 215
     Logger.log(LogError, 'command failed: ' .. ret)
197 216
   end
198 217
 end
199
-

modules/addon_console/console.otmod → modules/addon_terminal/terminal.otmod View File

@@ -1,17 +1,16 @@
1 1
 Module
2
-  name: console
3
-  description: Console for executing lua functions
2
+  name: terminal
3
+  description: Terminal for executing lua functions
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient
6 6
 
7
-  // console can be loaded after core
8 7
   autoLoad: true
9 8
   autoLoadPriority: 1000
10 9
 
11 10
   onLoad: |
12
-    require 'console'
11
+    require 'terminal'
13 12
     require 'commands'
14
-    Console.init()
13
+    Terminal.init()
15 14
 
16 15
   onUnload: |
17
-    Console.terminate()
16
+    Terminal.terminate()

modules/addon_console/console.otui → modules/addon_terminal/terminal.otui View File

@@ -1,15 +1,15 @@
1
-ConsoleLabel < UILabel
1
+TerminalLabel < UILabel
2 2
   font: terminus-14px-bold
3 3
   height: 16
4 4
 
5 5
 RectPanel
6
-  id: consolePanel
6
+  id: terminalPanel
7 7
   background-color: #000000
8 8
   opacity: 216
9 9
   anchors.fill: parent
10 10
 
11 11
   Panel
12
-    id: consoleBuffer
12
+    id: terminalBuffer
13 13
     layout: verticalBox
14 14
     focusable: false
15 15
     anchors.left: parent.left

+ 9
- 5
modules/client_about/about.lua View File

@@ -1,16 +1,20 @@
1 1
 About = {}
2 2
 
3 3
 -- private variables
4
-local aboutWindow
4
+local aboutButton
5 5
 
6 6
 -- public functions
7
-function About.create()
7
+function About.init()
8
+  aboutButton = TopMenu.addRightButton('aboutButton', 'About', '/core_styles/icons/about.png', About.display)
9
+end
10
+
11
+function About.display()
8 12
   aboutWindow = displayUI('about.otui', { locked = true })
9 13
 end
10 14
 
11
-function About.destroy()
12
-  aboutWindow:destroy()
13
-  aboutWindow = nil
15
+function About.terminate()
16
+  aboutButton:destroy()
17
+  aboutButton = nil
14 18
 end
15 19
 
16 20
 function About.openWebpage()

+ 4
- 0
modules/client_about/about.otmod View File

@@ -6,3 +6,7 @@ Module
6 6
 
7 7
   onLoad: |
8 8
     require 'about'
9
+    About.init()
10
+
11
+  onUnload:
12
+    About.terminate()

+ 1
- 1
modules/client_about/about.otui View File

@@ -58,4 +58,4 @@ MainWindow
58 58
     anchors.top: parent.top
59 59
     margin-top: 191
60 60
     margin-left: 188
61
-    @onClick: About.destroy()
61
+    @onClick: self:getParent():destroy()

+ 2
- 2
modules/client_background/background.lua View File

@@ -4,11 +4,11 @@ Background = { }
4 4
 local background
5 5
 
6 6
 -- public functions
7
-function Background.create()
7
+function Background.init()
8 8
   background = displayUI('background.otui')
9 9
 end
10 10
 
11
-function Background.destroy()
11
+function Background.terminate()
12 12
   background:destroy()
13 13
   background = nil
14 14
 end

+ 2
- 2
modules/client_background/background.otmod View File

@@ -6,8 +6,8 @@ Module
6 6
 
7 7
   onLoad: |
8 8
     require 'background'
9
-    Background.create()
9
+    Background.init()
10 10
 
11 11
   onUnload:
12
-    Background.destroy()
12
+    Background.terminate()
13 13
 

+ 23
- 4
modules/client_entergame/entergame.lua View File

@@ -5,6 +5,9 @@ local loadBox
5 5
 local enterGame
6 6
 local motdNumber
7 7
 local motdMessage
8
+local motdButton
9
+local enterGameButton
10
+
8 11
 
9 12
 -- private functions
10 13
 local function clearAccountFields()
@@ -25,7 +28,7 @@ end
25 28
 local function onMotd(protocol, motd)
26 29
   motdNumber = tonumber(motd:sub(0, motd:find("\n")))
27 30
   motdMessage = motd:sub(motd:find("\n") + 1, #motd)
28
-  TopMenu.getButton('motdButton'):show()
31
+  motdButton:show()
29 32
 end
30 33
 
31 34
 local function onCharacterList(protocol, characters, premDays)
@@ -50,7 +53,10 @@ local function onCharacterList(protocol, characters, premDays)
50 53
 end
51 54
 
52 55
 -- public functions
53
-function EnterGame.create()
56
+function EnterGame.init()
57
+  enterGameButton = TopMenu.addButton('enterGameButton', 'Login', '/core_styles/icons/login.png', EnterGame.openWindow)
58
+  motdButton = TopMenu.addButton('motdButton', 'Message of the day', '/core_styles/icons/motd.png', EnterGame.displayMotd)
59
+  motdButton:hide()
54 60
   enterGame = displayUI('entergame.otui')
55 61
 
56 62
   local account = Settings.get('account')
@@ -72,9 +78,13 @@ function EnterGame.create()
72 78
   end
73 79
 end
74 80
 
75
-function EnterGame.destroy()
81
+function EnterGame.terminate()
76 82
   enterGame:destroy()
77 83
   enterGame = nil
84
+  enterGameButton:destroy()
85
+  enterGameButton = nil
86
+  motdButton:destroy()
87
+  motdButton = nil
78 88
 end
79 89
 
80 90
 function EnterGame.show()
@@ -86,6 +96,14 @@ function EnterGame.hide()
86 96
   enterGame:hide()
87 97
 end
88 98
 
99
+function EnterGame.openWindow()
100
+  if Game.isOnline() then
101
+    CharacterList.show()
102
+  elseif not CharacterList.isVisible() then
103
+    EnterGame.show()
104
+  end
105
+end
106
+
89 107
 function EnterGame.doLogin()
90 108
   EnterGame.account = enterGame:getChildById('accountNameLineEdit'):getText()
91 109
   EnterGame.password = enterGame:getChildById('accountPasswordLineEdit'):getText()
@@ -111,5 +129,6 @@ function EnterGame.doLogin()
111 129
 end
112 130
 
113 131
 function EnterGame.displayMotd()
114
-  displayInfoBox("Message of the day", motdMessage)
132
+  displayInfoBox('Message of the day', motdMessage)
115 133
 end
134
+

+ 2
- 2
modules/client_entergame/entergame.otmod View File

@@ -7,9 +7,9 @@ Module
7 7
   onLoad: |
8 8
     require 'entergame'
9 9
     require 'characterlist'
10
-    EnterGame.create()
10
+    EnterGame.init()
11 11
 
12 12
   onUnload:
13
-    EnterGame.destroy()
13
+    EnterGame.terminate()
14 14
 
15 15
 

+ 11
- 0
modules/client_options/options.lua View File

@@ -1,5 +1,16 @@
1 1
 Options = {}
2 2
 
3
+local optionsButton
4
+
5
+function Options.init()
6
+  optionsButton = TopMenu.addButton('settingsButton', 'Options', '/core_styles/icons/settings.png', Options.show)
7
+  Options.load()
8
+end
9
+
10
+function Options.terminate()
11
+  TopMenu.removeButton(optionsButton)
12
+end
13
+
3 14
 function Options.load()
4 15
   local booleanOptions = { vsync = true,
5 16
                            showfps = true,

+ 3
- 1
modules/client_options/options.otmod View File

@@ -6,5 +6,7 @@ Module
6 6
 
7 7
   onLoad: |
8 8
     require 'options'
9
-    Options.load()
9
+    Options.init()
10 10
 
11
+  onUnload:
12
+    Options.terminate()

+ 60
- 3
modules/client_topmenu/topmenu.lua View File

@@ -2,17 +2,74 @@ TopMenu = {}
2 2
 
3 3
 -- private variables
4 4
 local topMenu
5
+local leftButtonsPanel
6
+local rightButtonsPanel
5 7
 
6 8
 -- public functions
7
-function TopMenu.create()
9
+function TopMenu.init()
8 10
   topMenu = displayUI('topmenu.otui')
11
+  leftButtonsPanel = topMenu:getChildById('leftButtonsPanel')
12
+  rightButtonsPanel = topMenu:getChildById('rightButtonsPanel')
13
+
14
+  TopMenu.addRightButton('logoutButton', 'Logout', '/core_styles/icons/logout.png',
15
+    function()
16
+      if Game.isOnline() then
17
+        Game.logout(false)
18
+      else
19
+        exit()
20
+      end
21
+    end
22
+  )
9 23
 end
10 24
 
11
-function TopMenu.destroy()
25
+function TopMenu.terminate()
26
+  leftButtonsPanel = nil
27
+  rightButtonsPanel = nil
12 28
   topMenu:destroy()
13 29
   topMenu = nil
14 30
 end
15 31
 
32
+function TopMenu.addButton(id, description, icon, callback, right)
33
+  local panel
34
+  local class
35
+  if right then
36
+    panel = rightButtonsPanel
37
+    class = 'TopRightButton'
38
+  else
39
+    panel = leftButtonsPanel
40
+    class = 'TopLeftButton'
41
+  end
42
+
43
+  local button = createWidget(class, panel)
44
+  button:setId(id)
45
+  button:setTooltip(description)
46
+  button:setIcon(resolvepath(icon, 2))
47
+  button.onClick = callback
48
+  return button
49
+end
50
+
51
+function TopMenu.addLeftButton(id, description, icon, callback)
52
+  return TopMenu.addButton(id, description, icon, callback, false)
53
+end
54
+
55
+function TopMenu.addRightButton(id, description, icon, callback)
56
+  return TopMenu.addButton(id, description, icon, callback, true)
57
+end
58
+
59
+function TopMenu.removeButton(param)
60
+  local button
61
+  if type(param) == 'string' then
62
+    button = TopMenu.getButton(param)
63
+  else
64
+    button = param
65
+  end
66
+  button:destroy()
67
+end
68
+
16 69
 function TopMenu.getButton(id)
17
-  return topMenu:getChildById(id)
70
+  return topMenu:recursiveGetChildById(id)
71
+end
72
+
73
+function TopMenu:getLogoutButton(id)
74
+  return TopMenu.getButton('logoutButton')
18 75
 end

+ 2
- 2
modules/client_topmenu/topmenu.otmod View File

@@ -6,7 +6,7 @@ Module
6 6
 
7 7
   onLoad: |
8 8
     require 'topmenu'
9
-    TopMenu.create()
9
+    TopMenu.init()
10 10
 
11 11
   onUnload: |
12
-    TopMenu.destroy()
12
+    TopMenu.terminate()

+ 52
- 47
modules/client_topmenu/topmenu.otui View File

@@ -1,67 +1,72 @@
1
-TopPanel
2
-  id: topMenu
3
-  anchors.top: parent.top
4
-  anchors.left: parent.left
5
-  anchors.right: parent.right
6
-  focusable: false
1
+TopButton < UIButton
2
+  background-color: white
3
+  size: 26 26
4
+  text-translate: 0 0
5
+  border-image:
6
+    source: /core_styles/images/top_button.png
7
+    clip: 0 0 26 26
8
+    border: 3
9
+
10
+  $hover:
11
+    border-image:
12
+      source: /core_styles/images/top_button.png
13
+      clip: 26 0 26 26
14
+      border: 3
15
+
16
+  $pressed:
17
+    text-translate: 1 1
18
+    border-image:
19
+      source: /core_styles/images/top_button.png
20
+      clip: 52 0 26 26
21
+      border: 3
7 22
 
8
-  TopButton
9
-    id: settingsButton
23
+  $disabled:
24
+    background-color: #ffffff66
25
+
26
+TopLeftButton < TopButton
27
+  $first:
10 28
     anchors.top: parent.top
11 29
     anchors.left: parent.left
12 30
     margin-top: 4
13 31
     margin-left: 6
14
-    tooltip: Options
15
-    icon: /core_styles/icons/settings.png
16
-    @onClick: Options.show()
17
-
18 32
 
19
-  TopButton
20
-    id: enterGameButton
33
+  $!first:
21 34
     anchors.top: prev.top
22 35
     anchors.left: prev.right
23 36
     margin-left: 6
24
-    tooltip: Enter game with a character
25
-    icon: /core_styles/icons/login.png
26
-    @onClick: |
27
-      if Game.isOnline() then
28
-        CharacterList.show()
29
-      elseif not CharacterList.isVisible() then
30
-        EnterGame.show()
31
-      end
32 37
 
33
-  TopButton
34
-    id: motdButton
35
-    anchors.top: prev.top
36
-    anchors.left: prev.right
37
-    margin-left: 6
38
-    tooltip: Message of the day
39
-    icon: /core_styles/icons/motd.png
40
-    visible: false
41
-    @onClick: EnterGame.displayMotd()
42
-
43
-  TopButton
38
+TopRightButton < TopButton
39
+  $first:
44 40
     anchors.top: parent.top
45 41
     anchors.right: parent.right
46 42
     margin-top: 4
47 43
     margin-right: 6
48
-    tooltip: Logout
49
-    icon: /core_styles/icons/logout.png
50
-    @onClick: |
51
-      if Game.isOnline() then
52
-        Game.logout(false)
53
-      else
54
-        exit()
55
-      end
56 44
 
57
-  TopButton
58
-    anchors.top: parent.top
45
+  $!first:
46
+    anchors.top: prev.top
59 47
     anchors.right: prev.left
60
-    margin-top: 4
61 48
     margin-right: 6
62
-    tooltip: About OTClient
63
-    icon: /core_styles/icons/about.png
64
-    @onClick: About.create()
49
+
50
+TopPanel
51
+  id: topMenu
52
+  anchors.top: parent.top
53
+  anchors.left: parent.left
54
+  anchors.right: parent.right
55
+  focusable: false
56
+
57
+  Panel
58
+    id: leftButtonsPanel
59
+    anchors.top: parent.top
60
+    anchors.bottom: parent.bottom
61
+    anchors.left: parent.left
62
+    anchors.right: next.left
63
+
64
+  Panel
65
+    id: rightButtonsPanel
66
+    anchors.top: parent.top
67
+    anchors.bottom: parent.bottom
68
+    anchors.right: parent.right
69
+    width: 60
65 70
 
66 71
   FrameCounter
67 72
     id: frameCounter

BIN
modules/core_styles/icons/terminal.png View File


+ 0
- 25
modules/core_styles/styles/buttons.otui View File

@@ -24,28 +24,3 @@ Button < UIButton
24 24
     color: #f0ad4d88
25 25
     background-color: #ffffff88
26 26
 
27
-TopButton < UIButton
28
-  background-color: white
29
-  size: 26 26
30
-  text-translate: 0 0
31
-  border-image:
32
-    source: /core_styles/images/top_button.png
33
-    clip: 0 0 26 26
34
-    border: 3
35
-
36
-  $hover:
37
-    border-image:
38
-      source: /core_styles/images/top_button.png
39
-      clip: 26 0 26 26
40
-      border: 3
41
-
42
-  $pressed:
43
-    text-translate: 1 1
44
-    border-image:
45
-      source: /core_styles/images/top_button.png
46
-      clip: 52 0 26 26
47
-      border: 3
48
-
49
-  $disabled:
50
-    background-color: #ffffff66
51
-

+ 1
- 1
src/framework/luascript/luaobject.h View File

@@ -63,7 +63,7 @@ public:
63 63
 
64 64
     /// Returns the class name used in Lua
65 65
     virtual std::string getLuaObjectName() const {
66
-        // this could later be cached for more performance
66
+        // TODO: this could be cached for more performance
67 67
         return Fw::demangleName(typeid(*this).name());
68 68
     }
69 69
 

+ 19
- 0
src/framework/otml/otmlnode.cpp View File

@@ -95,6 +95,13 @@ void OTMLNode::addChild(const OTMLNodePtr& newChild)
95 95
         for(const OTMLNodePtr& node : m_children) {
96 96
             if(node->tag() == newChild->tag() && (node->isUnique() || newChild->isUnique())) {
97 97
                 newChild->setUnique(true);
98
+
99
+                if(node->hasChildren() && newChild->hasChildren()) {
100
+                    OTMLNodePtr tmpNode = node->clone();
101
+                    tmpNode->merge(newChild);
102
+                    newChild->copy(tmpNode);
103
+                }
104
+
98 105
                 replaceChild(node, newChild);
99 106
 
100 107
                 // remove any other child with the same tag
@@ -140,6 +147,18 @@ bool OTMLNode::replaceChild(const OTMLNodePtr& oldChild, const OTMLNodePtr& newC
140 147
     return false;
141 148
 }
142 149
 
150
+void OTMLNode::copy(const OTMLNodePtr& node)
151
+{
152
+    setTag(node->tag());
153
+    setValue(node->value());
154
+    setUnique(node->isUnique());
155
+    setNull(node->isNull());
156
+    setSource(node->source());
157
+    clear();
158
+    for(const OTMLNodePtr& child : node->m_children)
159
+        addChild(child->clone());
160
+}
161
+
143 162
 void OTMLNode::merge(const OTMLNodePtr& node)
144 163
 {
145 164
     for(const OTMLNodePtr& child : node->m_children)

+ 1
- 0
src/framework/otml/otmlnode.h View File

@@ -63,6 +63,7 @@ public:
63 63
     void addChild(const OTMLNodePtr& newChild);
64 64
     bool removeChild(const OTMLNodePtr& oldChild);
65 65
     bool replaceChild(const OTMLNodePtr& oldChild, const OTMLNodePtr& newChild);
66
+    void copy(const OTMLNodePtr& node);
66 67
     void merge(const OTMLNodePtr& node);
67 68
     void clear();
68 69
 

+ 4
- 2
src/framework/ui/uilineedit.cpp View File

@@ -411,6 +411,9 @@ void UILineEdit::onFocusChange(bool focused, Fw::FocusReason reason)
411 411
 
412 412
 bool UILineEdit::onKeyPress(uchar keyCode, std::string keyText, int keyboardModifiers)
413 413
 {
414
+    if(UIWidget::onKeyPress(keyCode, keyText, keyboardModifiers))
415
+        return true;
416
+
414 417
     if(keyCode == Fw::KeyDelete) // erase right character
415 418
         removeCharacter(true);
416 419
     else if(keyCode == Fw::KeyBackspace) // erase left character {
@@ -433,8 +436,7 @@ bool UILineEdit::onKeyPress(uchar keyCode, std::string keyText, int keyboardModi
433 436
     } else if(!keyText.empty() && (keyboardModifiers == Fw::KeyboardNoModifier || keyboardModifiers == Fw::KeyboardShiftModifier))
434 437
         appendText(keyText);
435 438
     else
436
-        return UIWidget::onKeyPress(keyCode, keyText, keyboardModifiers);
437
-
439
+        return false;
438 440
     return true;
439 441
 }
440 442
 

+ 7
- 5
src/framework/ui/uiwidget.cpp View File

@@ -1116,8 +1116,12 @@ void UIWidget::onStyleApply(const std::string& styleName, const OTMLNodePtr& sty
1116 1116
         // anchors
1117 1117
         else if(boost::starts_with(node->tag(), "anchors.")) {
1118 1118
             UIWidgetPtr parent = getParent();
1119
-            if(!parent)
1120
-                throw OTMLException(node, "cannot create anchor, there is no parent widget!");
1119
+            if(!parent) {
1120
+                if(m_firstOnStyle)
1121
+                    throw OTMLException(node, "cannot create anchor, there is no parent widget!");
1122
+                else
1123
+                    continue;
1124
+            }
1121 1125
 
1122 1126
             UIAnchorLayoutPtr anchorLayout = parent->getLayout()->asUIAnchorLayout();
1123 1127
             if(!anchorLayout)
@@ -1331,9 +1335,7 @@ void UIWidget::propagateOnMouseRelease(const Point& mousePos, Fw::MouseButton bu
1331 1335
             child->setPressed(false);
1332 1336
     }
1333 1337
 
1334
-    // fire release events only when pressed
1335
-    if(isPressed())
1336
-        onMouseRelease(mousePos, button);
1338
+    onMouseRelease(mousePos, button);
1337 1339
 }
1338 1340
 
1339 1341
 bool UIWidget::propagateOnMouseMove(const Point& mousePos, const Point& mouseMoved)

Loading…
Cancel
Save