Skip to content

Properly relinquish activeFocus on ValueInput when editing is finished#255

Merged
hebasto merged 2 commits into
bitcoin-core:mainfrom
jarolrod:valinput-focus-control
Feb 16, 2023
Merged

Properly relinquish activeFocus on ValueInput when editing is finished#255
hebasto merged 2 commits into
bitcoin-core:mainfrom
jarolrod:valinput-focus-control

Conversation

@jarolrod
Copy link
Copy Markdown
Contributor

@jarolrod jarolrod commented Feb 10, 2023

On master, pressing enter while editing a setting that has a ValueInput does not properly relinquish focus from the ValueInput, still leaving it in an editing state. This fixes that by:

a. Making ValueInput a TextInput instead of a TextEdit

  • TextEdit allows for multi-line input, so an enter in this would add a new line, which we don't want. There is no use case for a ValueInput to be multiple lines, it should only be one. Additionally, this prevents enter from signaling that editing is finished
  • TextInput is specifically for single line input. This QML type also allows us to do necessary validations with a validator, inputMask, and signal what kind of keyboard we want with inputMethodHints. Additionally, this allows for enter to signal that editing is finished.

b. Relinquishing focus on the ValueInput itself, by forcing focus back to the parent Setting.

Windows
Intel macOS
Apple Silicon macOS
ARM64 Android

There is no use case for a ValueInput that will be fed into a setting
to be multi-line in nature
This gives the focus back to the parent setting, relinquishing focus
on the ValueInput and moving it out of the edit state.
Copy link
Copy Markdown
Collaborator

@johnny9 johnny9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 90fd65b

@hebasto hebasto merged commit 7b8b81c into bitcoin-core:main Feb 16, 2023
johnny9 pushed a commit to johnny9/bitcoin-core-app that referenced this pull request Jul 4, 2025
…lueInput when editing is finished

c10442c qml: Give up focus on ValueInput when editing finished (jarolrod)
daeca18 qml: Make ValueInput a TextInput instead of a TextEdit (jarolrod)

Pull request description:

  On master, pressing `enter` while editing a setting that has a ValueInput does not properly relinquish focus from the ValueInput, still leaving it in an editing state. This fixes that by:

  a. Making ValueInput a [TextInput](https://doc.qt.io/qt-5/qml-qtquick-textinput.html#text-prop) instead of a [TextEdit](https://doc.qt.io/qt-5/qml-qtquick-textedit.html)
    - TextEdit allows for multi-line input, so an `enter` in this would add a new line, which we don't want. There is no use case for a ValueInput to be multiple lines, it should only be one. Additionally, this prevents `enter` from signaling that editing is finished
    - TextInput is specifically for single line input. This QML type also allows us to do necessary validations with a [validator](https://doc.qt.io/qt-5/qml-qtquick-textinput.html#validator-prop), [inputMask](https://doc.qt.io/qt-5/qml-qtquick-textinput.html#inputMask-prop), and signal what kind of keyboard we want with [inputMethodHints](https://doc.qt.io/qt-5/qml-qtquick-textinput.html#inputMethodHints-prop). Additionally, this allows for `enter` to signal that editing is finished.

  b. Relinquishing focus on the ValueInput itself, by forcing focus back to the parent Setting.

  [![Windows](https://img.shields.io/badge/OS-Windows-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/win64/insecure_win_gui.zip?branch=pull/255)
  [![Intel macOS](https://img.shields.io/badge/OS-Intel%20macOS-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/macos/insecure_mac_gui.zip?branch=pull/255)
  [![Apple Silicon macOS](https://img.shields.io/badge/OS-Apple%20Silicon%20macOS-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/macos_arm64/insecure_mac_arm64_gui.zip?branch=pull/255)
  [![ARM64 Android](https://img.shields.io/badge/OS-Android-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/android/insecure_android_apk.zip?branch=pull/255)

ACKs for top commit:
  johnny9:
    ACK c10442c

Tree-SHA512: 6b2d40b9f715b05b239112835eb9078ce5637005bbea28888161179ac8ea9f736471b8e734542a90538e1bfca0c0c41de426954d311852534859cf51431d755f
tx-signer450 added a commit to tx-signer450/gui-qml that referenced this pull request Oct 20, 2025
…lueInput when editing is finished

c10442cdfa31d8fe33a45155fa78a7bd760ebb75 qml: Give up focus on ValueInput when editing finished (jarolrod)
daeca18101bd58289897414116d192d6ce5d92f5 qml: Make ValueInput a TextInput instead of a TextEdit (jarolrod)

Pull request description:

  On master, pressing `enter` while editing a setting that has a ValueInput does not properly relinquish focus from the ValueInput, still leaving it in an editing state. This fixes that by:

  a. Making ValueInput a [TextInput](https://doc.qt.io/qt-5/qml-qtquick-textinput.html#text-prop) instead of a [TextEdit](https://doc.qt.io/qt-5/qml-qtquick-textedit.html)
    - TextEdit allows for multi-line input, so an `enter` in this would add a new line, which we don't want. There is no use case for a ValueInput to be multiple lines, it should only be one. Additionally, this prevents `enter` from signaling that editing is finished
    - TextInput is specifically for single line input. This QML type also allows us to do necessary validations with a [validator](https://doc.qt.io/qt-5/qml-qtquick-textinput.html#validator-prop), [inputMask](https://doc.qt.io/qt-5/qml-qtquick-textinput.html#inputMask-prop), and signal what kind of keyboard we want with [inputMethodHints](https://doc.qt.io/qt-5/qml-qtquick-textinput.html#inputMethodHints-prop). Additionally, this allows for `enter` to signal that editing is finished.

  b. Relinquishing focus on the ValueInput itself, by forcing focus back to the parent Setting.

  [![Windows](https://img.shields.io/badge/OS-Windows-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/win64/insecure_win_gui.zip?branch=pull/255)
  [![Intel macOS](https://img.shields.io/badge/OS-Intel%20macOS-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/macos/insecure_mac_gui.zip?branch=pull/255)
  [![Apple Silicon macOS](https://img.shields.io/badge/OS-Apple%20Silicon%20macOS-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/macos_arm64/insecure_mac_arm64_gui.zip?branch=pull/255)
  [![ARM64 Android](https://img.shields.io/badge/OS-Android-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/android/insecure_android_apk.zip?branch=pull/255)

ACKs for top commit:
  johnny9:
    ACK c10442cdfa31d8fe33a45155fa78a7bd760ebb75

Tree-SHA512: 6b2d40b9f715b05b239112835eb9078ce5637005bbea28888161179ac8ea9f736471b8e734542a90538e1bfca0c0c41de426954d311852534859cf51431d755f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants