Delphi - Keep highlighted selection in RichEdit when focus is lost - delphi

I have an TRichEdit.
When I select some text and click on another element, the selection of the selected text disappears.
Is there a way to keep this selection, also when the TRichEdit has los it's focus?
Thanks!

TRichEdit has a property HideSelection which is True by default. If set to False then the selection will still be visible even when the TRichEdit does not have focus.
BTW: the propery HideSelectionexists on other controls as well. It is also very usefull on a TListView or a TTreeView when you are showing details of the selected item in the listview or treeview.

Related

Show selection of TEdit that does not have focus

I have a FireMonkey application and I need to change what is selected in Edit1 while the user is typing in Edit2. To be exact, Edit1 has some sample text and Edit2 has a regular expression that the user is editing. I want the user to be able to see if the regular expression is valid and what the matched text would be for the given sample text.
I'm using the OnChangeTracking event of Edit2 to set the SelStart and SelLength of Edit1.
The problem is, unlike VCL's TEdit, FireMonkey's TEdit does not have a HideSelection property, and always hides the selected text if the control does not have the input focus.
Is there a way to change this behavior and force the selection highlight to show no matter which control has input focus?

How to add some buttons to selected ListBox item via style?

Is there a way to add some buttons to the selected ListBoxItem by adding these buttons to a style which is being used for the selected item?
I didn't yet find a suitable style FMX uses to display the selected item.
My goal is to have some buttons on the selected item with context based functionality. While I can do this by reparenting a TButton created in code in the OnPaint event of the ListBox, this works for Android but not for Win32 as it is being overpainted by the selection.
Other solutions like doing this in OnItemClick or OnClick are sluggish or only work properly on Win32 but not on Android and would need to be put into a timer fired on click.

Delphi: Using TextHint in a multiline text component such as TMemo or TRichEdit

TextHint is the TEdit property which let's you display a greyed text hint inside the textbox, when the textbox is empty.
I want to place the same kind of hint in a TMemo, or TRichEdit, since the TEdit component does not allow multiline.
How can I use a TextHint inside a multiline text control in Delphi?
The TextHint property actually exists in TMemo and TrichEdit components, but it seems to have no effect.
Thank you in advance.
The TextHint property is implemented using the EM_SETCUEBANNER message. Windows itself simply does not support that message on those UI controls:
You cannot set a cue banner on a multiline edit control or on a rich
edit control.

How to simulate OnMouseMove event on TMenuItem?

When mouse cursor is over some menu item (TMainMenu) then the item is highlighted. I would like to add a text inside my status bar describing the menu item but I have no OnMouseMove or any similiar event for TMenuItem to do this. How to achive this?
I'm using C++ Builder XE6.
Thanks!
The VCL can handle this automatically for you.
Assign your desired text to the TMenuItem.Hint property:
Specifies the text string that can appear when the user moves the mouse pointer over a menu item.
Set Hint to a string that provides more information about the meaning of the menu item than the Caption. The hint text appears in the Status Bar when the user pauses with the mouse over the menu item if Help Hints are enabled (that is, if the Form's and the Application's ShowHint properties are True). It is also available for the code in the application's OnHint event handler.
And then set the TStatusBar.AutoHint property to true.
Specifies whether the status bar's text is set automatically to the current hint.
Use AutoHint to specify whether the status bar's text is set automatically to the current hint. When AutoHint is True, the status bar automatically responds to hint actions by displaying the long version of the hint's text in the first panel.
Any changes to the TApplication.Hint property, such as when the mouse moves over a UI control or menu item, will propagate to the TStatusBar automatically.

In Delphi, how can I force tListView to always show selected row, even when not focused.

The selected row of a tListView appears blue, but only when the control has focus. I'd like the selected row to always be displayed, whether the control has focus or not.
Set the HideSelection property to False.
Determines whether the list view gives a visual indication of which item is selected when focus shifts to another control.
Set HideSelection to false to provide visual feedback of the selected item in the list even when the list view does not have focus. Set HideSelection to true to show the selection only when the list view has focus. HideSelection does not affect the actual value of the selection, only the visual indication. Always setting HideSelection to false can make forms with many list views look too busy.

Resources