Show selection of TEdit that does not have focus - delphi

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?

Related

When typing at the end of the editmask, it will pass the number to the left side until it reaches the last one

Good afternoon,
I'm doing a project in delphi that uses editmask. I'm using the phone mask.
When clicking on edit to write the phone number, it goes to the last field on the right, so it is necessary to go back with the backspace to the beginning of the edit on the left.
i would like to find a way that when the user typed the number in the last field on the right, it was passed to the left. So on until you complete the phone field. It would be possible?
Using an example of what it would look like:
I couldn't think of a way to do it
The component is called TMaskEdit.
Just like anything that bases on TEdit putting the focus onto the control will by default put the text cursor at the end of its content
via keyboard, should .AutoSelect be FALSE and
via mouse if clicking behind any text (by default the text is aligned to the left).
You should have experienced this with the other components already. If you want the text cursor to always be at a certain position upon focusing the control, then do that in such an event handler:
for keyboard use OnEnter:
procedure TForm1.MaskEdit1Enter(Sender: TObject);
begin
(Sender as TMaskEdit).SelStart:= 1; // Second position
end;
and for mouse use OnClick with the same code.
It even works unbound to how the property .AutoSelect is set.
Using Backspace is the worst choice input wise, as it always deletes potential content and needs to be pressed several times to go to the first position. Why not using the Home key instead?

X,Y coordinates of text cursor position

How to find out X,Y screen coordinates of a text cursor in a control whatever is focused at current time? It may be TEdit, TMemo or any other control with text cursor.
I need it in order to display a window with a choice of alternative characters user can enter. This window should pop up on a special key combination, with its top left corner near to the caret in currently active editor. Because I did'nt want to make individual processing for each editing control, I do it application wide in Application.OnMessage handler.
GetCaretPos can do the trick.
It works like
if Windows.GetCaretPos(cp) and Windows.ClientToScreen(GetFocus(), cp) then begin
//.......
end;

How to make a VirtualTreeView's Node allow TMemo like multiline keyboard input instead of the TEdit like default behavior?

I am modifying the MultilineDemo that comes with VirtualTreeView's git folder (Virtual-TreeView-master\Demos\Advanced). I have just removed the multiline 'display' code and added code to the VST's onClick handler to make the clicked node editable.
I want to enter multiline text into a node like TMemo but, the enter or shift+enter key presses finish the editing. See the image below. I couldn't find a keypress event for a node in VST property panel for modifying the default behavior. My goal is to have a tree like control with nodes capable of multiline input
I don't think I have to post any code from my current application.
You need to implement your own IVTEditLink editor, create a memo control and handle its key down event. See the /Demos/Advanced/Editors.pas unit for vtMemo type of values. It does almost what you want. It shows how to create a memo control as a node editor and how to handle the editor's control key down event (in this case the EditKeyDown method).

Delphi combobox csOwnerDrawFixed set text property

I am using the csOwnerDrawFixed style to incorporate my style into a TCombobox. The problem is that I can no longer use the Text Property. I suppose it is read only. Is there a way to enable the text property?
No this is not possible. What you are observing is a simple reflection of the underlying Win32 control's behaviour.
When you select the csOwnerDrawFixed style that is mapped to the combo box CBS_OWNERDRAWFIXED style. And when a combo box has that style, then WM_SETTEXT always fails with CB_ERR, and WM_GETTEXT always returns an empty string.
The reason for this is that when you use the csOwnerDrawFixed style then the combo box does not have an associated edit control. Therefore there is nowhere for it to store window text. You only get an associated edit control if the combo box style is csDropDown or csSimple.

Delphi - Keep highlighted selection in RichEdit when focus is lost

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.

Resources