Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Hunger
qt-creator
Commits
50587a31
Commit
50587a31
authored
Jan 08, 2010
by
Christiaan Janssen
Browse files
QmlDesigner.StatesEditor: Improving focus management of TextInputs for state renaming
parent
fec96d4c
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/plugins/qmldesigner/components/stateseditor/stateslist.qml
View file @
50587a31
...
...
@@ -27,8 +27,10 @@ Rectangle {
signal
:
"
changedToState(n)
"
script
:
{
root
.
currentStateIndex
=
n
}
}
Item
{
id
:
focusStealer
}
// TextInputs don't loose focus automatically when user clicks away, have to be done explicitly
signal
unFocus
Item
{
id
:
focusStealer
}
Flickable
{
id
:
listView
...
...
@@ -94,34 +96,38 @@ Rectangle {
anchors.fill
:
container
onClicked
:
{
root
.
currentStateIndex
=
index
focusStealer
.
focus
=
true
;
// steal focus from textinput
root
.
unFocus
();
}
}
Connection
{
sender
:
root
signal
:
"
unFocus()
"
script
:
txt
.
unFocus
()
}
TextInput
{
anchors.top
:
img
.
bottom
anchors.horizontalCenter
:
img
.
horizontalCenter
id
:
txt
text
:
stateName
color
:
"
#E1E1E1
"
;
onAccepted
:
{
// force focus to move to another item, otherwise this one will be reactivated at mode change
function
unFocus
()
{
focus
=
false
;
itemRegion
.
focus
=
true
;
}
onFocusChanged
:
if
(
!
focus
)
{
txtRegion
.
enabled
=
true
statesEditorModel
.
renameState
(
index
,
text
)
focusStealer
.
focus
=
true
;
txtRegion
.
enabled
=
true
;
if
(
index
!=
0
)
statesEditorModel
.
renameState
(
index
,
text
);
}
onAccepted
:
unFocus
();
MouseRegion
{
id
:
txtRegion
anchors.fill
:
parent
property
bool
wasDoubleClicked
:
false
onClicked
:
{
root
.
currentStateIndex
=
index
;
itemRegion
.
focus
=
true
;
root
.
unFocus
()
;
}
onDoubleClicked
:
if
(
index
!=
0
)
{
// base state not editable
onDoubleClicked
:
if
(
index
!=
0
)
{
parent
.
focus
=
true
;
enabled
=
false
;
}
...
...
@@ -185,6 +191,7 @@ Rectangle {
MouseRegion
{
anchors.fill
:
parent
onClicked
:
{
root
.
unFocus
();
if
(
root
.
currentStateIndex
==
0
)
root
.
createNewState
();
//create new state
else
...
...
@@ -249,6 +256,7 @@ Rectangle {
MouseRegion
{
anchors.fill
:
parent
onClicked
:
{
root
.
unFocus
();
root
.
deleteCurrentState
();
if
(
root
.
currentStateIndex
>=
statesEditorModel
.
count
)
root
.
currentStateIndex
=
root
.
currentStateIndex
-
1
;
...
...
@@ -312,7 +320,7 @@ Rectangle {
anchors.fill
:
parent
property
int
dragging
:
0
;
property
int
originalX
:
0
;
onPressed
:
{
dragging
=
1
;
originalX
=
mouse
.
x
;
}
onPressed
:
{
dragging
=
1
;
originalX
=
mouse
.
x
;
root
.
unFocus
();
}
onReleased
:
{
dragging
=
0
;
}
onPositionChanged
:
if
(
dragging
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment