How to hide selection handles on QtQuickControls2 TextField? - qt

I use QtVirtualKeyboard in my QML app and as a result selection handles appear whenever some text is selected in a TextField:
Is there any way to hide these handles? Nothing in TextField or TextInput docs mention anything about this.

You can hide the handle by setting the InputMethodHint flag in the TextField to Qt.ImhNoTextHandles. That should get rid of the handle. ref https://doc.qt.io/qt-5/qt.html

Related

qml how to keep focus on TextField

I want to keep focus on TextField. For example i am typing something then tap to button. The focus on TextField is moving to button, that's why keyboard is automatically hiding on Android. I am using Qt 5.9.2. Thanks in advance!
In Qt Quick Controls 2, each control has a focusPolicy property which determines how the control gets focus. The default for controls like Button is Qt.StrongFocus, which means that buttons get focus after being clicked or tabbed into. If you're seeing that a control has focus and you don't want it to, just set its focusPolicy to Qt.NoFocus:
focusPolicy: Qt.NoFocus

Keep Selection in JavaFX Textfield even if application is not focussed

Background:
I'm trying to implement a find/replace function for java-Fx table view. Whenever I find an occurance of the text to find, I switch the table view into edit mode and select the text found programatically in the textfield which is used during edit mode.
The focus in this situation remains in the modal find/replace dialog, so the selection in the textfield is not visible until I close the modal dialog.
The problem:
A textfield in Java-Fx shows it's selection only while it has the focus (as its standard behaviour). When the Java-Application loses focus the selection becomes invisible, when it gets the focus back the selection is visible again.
Here is the question:
Is it possible to keep the selection visible in a textfield though focus is lost?
What I tried:
I expected that CSS could help here:
textField.setStyle("-fx-highlight-fill: lightgray");
This changes the color of the highlighting but
I wanted to keep the original color for the focussed Textfield
I wanted to change the color from"invisible" to "lightgray" only for
the non-focussed Textfield
What is the correct way?
Or is there a way to highlight text in a TableView without activating the TextField?
Thanks
Ingo
If I am understanding correctly, the solution will be in the modality of your find/replace dialog.
It works for me when I do the following: Note that the java file this is written in extends Stage. If you are not extending stage then just call the methods on your find/replace stage.
owner = myApplicationStage;
initModality(Modality.NONE);//important for the solution!
initOwner(owner);
initStyle(StageStyle.UTILITY);
setScene(myFindAndReplaceScene);
stage = this;
stage.show();
This works perfectly for me, if you have any problems then hopefully I can help.

How to select TextEdit after Enabled in Qt?

I want to design a layout with a PushButton and TextEdit. The TextEdit is disabled at first and only enabled when the PushButton is clicked. When the TextEdit is enabled, it should also be selected.
In other words, what I mean is I can start typing straightway in the TextEdit without click to select it after it is enabled. Like when you open a new tab in your browser, the text cursor will automatically go to the address bar without any clicking.
Thanks.
You can use the QWidget::setFocus() function, docs here.

Disable Flex DateField component from user input

I have a DateField component in Flex and I want to stop any user input. If I set the editable to "false" then it stops users changed the bits of the DateField box. It does NOT however stop them from clicking on the calendar icon next to it and updating the date. Is it possible to disable this?
I basically want the component to be read only under some circumstances but not for it to have any alpha overlay. Therefore I want to use editable rather than enabled.
Thanks for any help
Richard
You can use enabled, and then set the styles disabledColor to 0x000000 and disabledSkin to ScrollArrowSkin (The default for DateField, upSkin)

how can I write a generic property modification function in Flex/Actionscript3?

I'm new to Flex, although not new to programming. I want to write a generic event handler that will be called by all my textinput boxes when they receive focus. When they have focus, I want to change the colour of the textinput box. When they lose focus, I want to restore the "inactive" color profile. I could write an ActionScript event handler for each textinput box, but we all know that's lame. :o) What I need, then, is a way to access the object which is calling the event handler.
In Delphi, I'd have written a function which passes in the Sender object, allowing me to access the calling object's properties. I'm guessing ActionScript/Flex has a completely different architecture, which is why I'm having difficulty doing this.
Thanks in anticipation!
You should subclass TextInput and handle the focus events in there. I think this would be the simplest way to achieve what you are looking for without having any complex code.
I hope I'm understanding what you're asking for... are you talking about event delegation?
This worked for me:
// 'focusOut' for blur
stage.addEventListener('focusIn', function(e:Event):void {
// The focused control is e.target
});
If you want to change the look of the focused input box, you can do this by setting the focusSkin property. If you want this to happen globally, you can put a style declaration in your CSS file.
In this CSS example I'm replacing the default focusSkin (mx.skins.halo.HaloFocusRect) with an embedded PNG file.
TextInput {
focusSkin: Embed(source="focus.png");
}
TextInput has a few properties for altering the look of the focus, like changing the opacity of the focus skin (focusAlpha property). Check the TextInput documentation for more info.

Resources