Merge pull request #8171 from jherico/qml_fixes

Keyboard focus polish for Vive UI
This commit is contained in:
Ryan Downe Karpf 2016-07-01 16:20:36 -07:00 committed by GitHub
commit 7eb07cba4c
6 changed files with 32 additions and 24 deletions

View file

@ -36,15 +36,15 @@ SpinBox {
id: spinStyle id: spinStyle
background: Rectangle { background: Rectangle {
color: isLightColorScheme color: isLightColorScheme
? (spinBox.focus ? hifi.colors.white : hifi.colors.lightGray) ? (spinBox.activeFocus ? hifi.colors.white : hifi.colors.lightGray)
: (spinBox.focus ? hifi.colors.black : hifi.colors.baseGrayShadow) : (spinBox.activeFocus ? hifi.colors.black : hifi.colors.baseGrayShadow)
border.color: spinBoxLabelInside.visible ? spinBoxLabelInside.color : hifi.colors.primaryHighlight border.color: spinBoxLabelInside.visible ? spinBoxLabelInside.color : hifi.colors.primaryHighlight
border.width: spinBox.focus ? spinBoxLabelInside.visible ? 2 : 1 : 0 border.width: spinBox.activeFocus ? spinBoxLabelInside.visible ? 2 : 1 : 0
} }
textColor: isLightColorScheme textColor: isLightColorScheme
? (spinBox.focus ? hifi.colors.black : hifi.colors.lightGray) ? (spinBox.activeFocus ? hifi.colors.black : hifi.colors.lightGray)
: (spinBox.focus ? hifi.colors.white : hifi.colors.lightGrayText) : (spinBox.activeFocus ? hifi.colors.white : hifi.colors.lightGrayText)
selectedTextColor: hifi.colors.black selectedTextColor: hifi.colors.black
selectionColor: hifi.colors.primaryHighlight selectionColor: hifi.colors.primaryHighlight
@ -96,7 +96,7 @@ SpinBox {
anchors.fill: parent anchors.fill: parent
propagateComposedEvents: true propagateComposedEvents: true
onWheel: { onWheel: {
if(spinBox.focus) if(spinBox.activeFocus)
wheel.accepted = false wheel.accepted = false
else else
wheel.accepted = true wheel.accepted = true

View file

@ -36,14 +36,14 @@ TextField {
style: TextFieldStyle { style: TextFieldStyle {
textColor: isLightColorScheme textColor: isLightColorScheme
? (textField.focus ? hifi.colors.black : hifi.colors.lightGray) ? (textField.activeFocus ? hifi.colors.black : hifi.colors.lightGray)
: (textField.focus ? hifi.colors.white : hifi.colors.lightGrayText) : (textField.activeFocus ? hifi.colors.white : hifi.colors.lightGrayText)
background: Rectangle { background: Rectangle {
color: isLightColorScheme color: isLightColorScheme
? (textField.focus ? hifi.colors.white : hifi.colors.textFieldLightBackground) ? (textField.activeFocus ? hifi.colors.white : hifi.colors.textFieldLightBackground)
: (textField.focus ? hifi.colors.black : hifi.colors.baseGrayShadow) : (textField.activeFocus ? hifi.colors.black : hifi.colors.baseGrayShadow)
border.color: hifi.colors.primaryHighlight border.color: hifi.colors.primaryHighlight
border.width: textField.focus ? 1 : 0 border.width: textField.activeFocus ? 1 : 0
radius: isSearchField ? textField.height / 2 : 0 radius: isSearchField ? textField.height / 2 : 0
HiFiGlyphs { HiFiGlyphs {

View file

@ -30,6 +30,7 @@ FocusScope {
if (!repositionLocked) { if (!repositionLocked) {
d.handleSizeChanged(); d.handleSizeChanged();
} }
} }
onHeightChanged: d.handleSizeChanged(); onHeightChanged: d.handleSizeChanged();
@ -66,7 +67,6 @@ FocusScope {
if (desktop.repositionLocked) { if (desktop.repositionLocked) {
return; return;
} }
var oldRecommendedRect = recommendedRect; var oldRecommendedRect = recommendedRect;
var newRecommendedRectJS = (typeof Controller === "undefined") ? Qt.rect(0,0,0,0) : Controller.getRecommendedOverlayRect(); var newRecommendedRectJS = (typeof Controller === "undefined") ? Qt.rect(0,0,0,0) : Controller.getRecommendedOverlayRect();
var newRecommendedRect = Qt.rect(newRecommendedRectJS.x, newRecommendedRectJS.y, var newRecommendedRect = Qt.rect(newRecommendedRectJS.x, newRecommendedRectJS.y,
@ -311,8 +311,8 @@ FocusScope {
onPinnedChanged: { onPinnedChanged: {
if (pinned) { if (pinned) {
nullFocus.focus = true; desktop.focus = true;
nullFocus.forceActiveFocus(); desktop.forceActiveFocus();
// recalculate our non-pinned children // recalculate our non-pinned children
hiddenChildren = d.findMatchingChildren(desktop, function(child){ hiddenChildren = d.findMatchingChildren(desktop, function(child){
@ -486,17 +486,31 @@ FocusScope {
} }
function unfocusWindows() { function unfocusWindows() {
// First find the active focus item, and unfocus it, all the way
// up the parent chain to the window
var currentFocus = offscreenWindow.activeFocusItem;
var targetWindow = d.getDesktopWindow(currentFocus);
while (currentFocus) {
if (currentFocus === targetWindow) {
break;
}
currentFocus.focus = false;
currentFocus = currentFocus.parent;
}
// Unfocus all windows
var windows = d.getTopLevelWindows(); var windows = d.getTopLevelWindows();
for (var i = 0; i < windows.length; ++i) { for (var i = 0; i < windows.length; ++i) {
windows[i].focus = false; windows[i].focus = false;
} }
// For the desktop to have active focus
desktop.focus = true; desktop.focus = true;
desktop.forceActiveFocus();
} }
FocusHack { id: focusHack; } FocusHack { id: focusHack; }
FocusScope { id: nullFocus; }
Rectangle { Rectangle {
id: focusDebugger; id: focusDebugger;
objectName: "focusDebugger" objectName: "focusDebugger"
@ -510,5 +524,5 @@ FocusScope {
enabled: DebugQML enabled: DebugQML
onTriggered: focusDebugger.visible = !focusDebugger.visible onTriggered: focusDebugger.visible = !focusDebugger.visible
} }
} }

View file

@ -53,11 +53,6 @@ ScrollingWindow {
updateRunningScripts(); updateRunningScripts();
} }
function setDefaultFocus() {
// Work around FocusScope of scrollable window.
filterEdit.forceActiveFocus();
}
function updateRunningScripts() { function updateRunningScripts() {
var runningScripts = ScriptDiscoveryService.getRunning(); var runningScripts = ScriptDiscoveryService.getRunning();
runningScriptsModel.clear() runningScriptsModel.clear()
@ -276,7 +271,6 @@ ScrollingWindow {
isSearchField: true isSearchField: true
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
focus: true
colorScheme: hifi.colorSchemes.dark colorScheme: hifi.colorSchemes.dark
placeholderText: "Filter" placeholderText: "Filter"
onTextChanged: scriptsModel.filterRegExp = new RegExp("^.*" + text + ".*$", "i") onTextChanged: scriptsModel.filterRegExp = new RegExp("^.*" + text + ".*$", "i")

View file

@ -268,6 +268,7 @@ void handleOpenVrEvents() {
case vr::VREvent_KeyboardClosed: case vr::VREvent_KeyboardClosed:
_keyboardFocusObject = nullptr; _keyboardFocusObject = nullptr;
_keyboardShown = false; _keyboardShown = false;
DependencyManager::get<OffscreenUi>()->unfocusWindows();
break; break;
default: default:

View file

@ -125,7 +125,6 @@ Rectangle {
TextField { TextField {
id: addressLine id: addressLine
focus: true
anchors { anchors {
left: parent.left; right: parent.right; left: parent.left; right: parent.right;
top: row.bottom; margins: 16; top: row.bottom; margins: 16;