Topic: Blinking Cursor

Hi Everyone,
.
I have a question and it's a real low priority but I'm curious.
.
Is there any way to change the vertical blinking cursor   to something a little wider or maybe a different color?
.
Something to make it stand out a little more?
.
Thanks
Frank

Re: Blinking Cursor

I think that the cursor in the input field is the property of the operating system.


You can emulate field input by intercepting keystrokes with a form event handler and displaying the result, including your own "cursor" in the label. But in my opinion, the effort spent on this will be unjustified.

Визуальное программирование: блог и телеграм-канал.

Re: Blinking Cursor

Hi Frank, K245,
Rather than trying to make the flashing cursor more prominent, a different approach might be to make the object that the flashing cursor is currently placed in more prominent.
A simple way to do that would be to change the object background colour when it's got focus (nb this doesn't work for datetimepickers (but I believe that's a Windows constraint rather than MVD)).
Please see the attached.
Derek.

Post's attachments

Attachment icon frank highlight.zip 379.56 kb, 144 downloads since 2022-05-06 

Re: Blinking Cursor

Derek,
I think your solution looks really nice. Changing the background color for each Text field really shows the user where they are.
.
But, and there's always a but, I have so far about 8-10 forms and one of them has 29 fields.  So a rough estimate is that I would have to change approximately 200 fields to implement the fix throughout my application.  It's not a hard fix to do but could be time consuming.  I do like the fix though, so I'll have to think about whether I want to do it.
.
I did notice something interesting though.
- When I open a blank form the first text field has a normal white background ready to input black text.
- Then when I open the same form for editing that already has data, if the first field is a text field, then the text background is Blue.  And the text is White. Then when you move to the next field, the first text box returns to normal black text on a white background.
I'm thinking this must be something built in to MVD because I don't see any setting to make it happen?  It would be nice if that would happen automatically to all text fields.
.
Thanks
Frank

Re: Blinking Cursor

Hi Frank,
What you are seeing when you edit an existing record is that the CONTENTS of each field are being selected and highlighted (obviously this doesn't happen when creating a new record because the field is empty (ergo nothing to select and highlight)).
You can switch this off if desired by de-selecting the 'auto-select' property (see the screenshot in the attachment);
The behaviour should then look the same whether you are opening the form to create a new record or to edit an existing record.
Derek.

Post's attachments

Attachment icon frank highlight2.zip 461.82 kb, 164 downloads since 2022-05-07 

Re: Blinking Cursor

Derek,
Thanks for the suggestions.  I did not know what the AutoSelect setting was used for.
And to be honest, I'm embarrassed because AutoSelect does exactly what I was asking for. 
When a field (with data) is in focus the color changes to white text on a blue background.  Then when you exit the field it goes back to black on white.  Obviously it's been doing this all along and I just took it for granted.
.
What I didn't realize was that it does it for a field with data but not with an empty field.  But that's OK.
I usually like to blame it on the aliens, but in this case I have to give them a pass smile  It's all on me so just I'll blame it on a senior moment. Us old farts can usually get away with more stuff.  One of the very few benefits of getting older.
.
Thanks again for helping to educate me.
Frank

Re: Blinking Cursor

derek wrote:

Hi Frank, K245,
Rather than trying to make the flashing cursor more prominent, a different approach might be to make the object that the flashing cursor is currently placed in more prominent.
A simple way to do that would be to change the object background colour when it's got focus (nb this doesn't work for datetimepickers (but I believe that's a Windows constraint rather than MVD)).
Please see the attached.
Derek.

The code works, but I wouldn't recommend ignoring the actual component class. I'm not sure if they are all related to TdbEdit )))


You can automate the assignment of handlers:

procedure highlighton (Sender: TObject);
begin
  tdbedit(sender).color := $00BEDD9F;
end;

procedure highlightoff (Sender: TObject);
begin
  tdbedit(sender).color := clwhite;
end;

procedure AutoAssign;
var
  i,j: integer;
  tmpForm: TForm;
begin
  for i:=0 to Screen.FormCount - 1 do
  begin
    tmpForm := Screen.Forms[i];
    for j := 0 to tmpForm.ComponentCount - 1 do
    begin
      if (tmpForm.Components(j) is TdbEdit) // это верно на 100%
      or (tmpForm.Components(j) is TdbMemo) // это неправильно, но работает )))
      or (tmpForm.Components(j) is TdbComboBox) // это неправильно, но тоже работает )))
      then
      begin
        TdbEdit( tmpForm.Components(j) ).OnEnter :=  @highlighton;
        TdbEdit( tmpForm.Components(j) ).OnExit :=  @highlightoff;
      end;
    end;
  end;
end;

begin
  AutoAssign;
end.
Визуальное программирование: блог и телеграм-канал.

Re: Blinking Cursor

Привет Константин,
Я думал, что должен быть способ сделать это, но не мог получить правильный синтаксис.
Теперь я вижу, что мне нужно было сделать
       начинать
         TdbEdit( tmpForm.Components(j) ).OnEnter := @highlighton;
         TdbEdit( tmpForm.Components(j) ).OnExit := @highlightoff;
       конец;
Спасибо за это, это будет полезно для многих вещей.
Derek.
.
I thought there must be a way of doing this but couldn't get the correct syntax.
Now I see what I was needing to do
      begin
        TdbEdit( tmpForm.Components(j) ).OnEnter :=  @highlighton;
        TdbEdit( tmpForm.Components(j) ).OnExit :=  @highlightoff;
      end;
Thanks for this, it will be useful for many things.

Re: Blinking Cursor

derek wrote:

Привет Константин,
Я думал, что должен быть способ сделать это, но не мог получить правильный синтаксис.
Теперь я вижу, что мне нужно было сделать
       начинать
         TdbEdit( tmpForm.Components(j) ).OnEnter := @highlighton;
         TdbEdit( tmpForm.Components(j) ).OnExit := @highlightoff;
       конец;
Спасибо за это, это будет полезно для многих вещей.
Derek.
.
I thought there must be a way of doing this but couldn't get the correct syntax.
Now I see what I was needing to do
      begin
        TdbEdit( tmpForm.Components(j) ).OnEnter :=  @highlighton;
        TdbEdit( tmpForm.Components(j) ).OnExit :=  @highlightoff;
      end;
Thanks for this, it will be useful for many things.

It is more correct to cast each object to its true type:

if tmpForm.Components(j) is TdbEdit then
begin
  TdbEdit( tmpForm.Components(j) ).OnEnter :=  @highlighton;
  TdbEdit( tmpForm.Components(j) ).OnExit :=  @highlightoff;
end
else if tmpForm.Components(j) is TdbMemo then
begin
  TdbMemo( tmpForm.Components(j) ).OnEnter :=  @highlighton;
  TdbMemo( tmpForm.Components(j) ).OnExit :=  @highlightoff;
end
else if tmpForm.Components(j) is TdbComboBox then
begin
  TdbComboBox( tmpForm.Components(j) ).OnEnter :=  @highlighton;
  TdbComboBox( tmpForm.Components(j) ).OnExit :=  @highlightoff;
end;
Визуальное программирование: блог и телеграм-канал.