mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-19 08:18:05 +02:00
Shift key resets after first alpha key.
This commit is contained in:
parent
7b4b98971e
commit
69bda0de83
2 changed files with 30 additions and 8 deletions
|
@ -10,7 +10,7 @@ Item {
|
|||
property alias mouseArea: mouseArea1
|
||||
|
||||
function resetToggledMode(mode) {
|
||||
toggled: mode
|
||||
toggled = mode
|
||||
if (toggled) {
|
||||
state = "mouseDepressed"
|
||||
} else {
|
||||
|
|
|
@ -8,7 +8,7 @@ Item {
|
|||
|
||||
function resetShiftMode(mode) {
|
||||
shiftMode = mode
|
||||
key23.resetToggledMode(mode)
|
||||
shiftKey.resetToggledMode(mode)
|
||||
}
|
||||
|
||||
function toUpper(str) {
|
||||
|
@ -35,21 +35,43 @@ Item {
|
|||
}
|
||||
}
|
||||
|
||||
onShiftModeChanged: {
|
||||
function forEachKey(func) {
|
||||
var i, j;
|
||||
for (i = 0; i < column1.children.length; i++) {
|
||||
var row = column1.children[i];
|
||||
for (j = 0; j < row.children.length; j++) {
|
||||
var key = row.children[j];
|
||||
if (shiftMode) {
|
||||
key.glyph = keyboardBase.toUpper(key.glyph);
|
||||
} else {
|
||||
key.glyph = keyboardBase.toLower(key.glyph);
|
||||
}
|
||||
func(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onShiftModeChanged: {
|
||||
forEachKey(function (key) {
|
||||
if (shiftMode) {
|
||||
key.glyph = keyboardBase.toUpper(key.glyph);
|
||||
} else {
|
||||
key.glyph = keyboardBase.toLower(key.glyph);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function alphaKeyClickedHandler(mouseArea) {
|
||||
// reset shift mode to false after first keypress
|
||||
if (shiftMode) {
|
||||
resetShiftMode(false)
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
// hook up callbacks to every ascii key
|
||||
forEachKey(function (key) {
|
||||
if (/^[a-z]+$/i.test(key.glyph)) {
|
||||
key.mouseArea.onClicked.connect(alphaKeyClickedHandler);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: leftRect
|
||||
y: 0
|
||||
|
|
Loading…
Reference in a new issue