Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » LineEdit, EditFields, DocEdit » Uppercase in EditField and cursor position
Uppercase in EditField and cursor position [message #52265] Thu, 22 August 2019 12:59 Go to next message
Giorgio is currently offline  Giorgio
Messages: 218
Registered: August 2015
Experienced Member
Hi there,
I wrote a method to set uppercase the content of an EditField:

void UppercaseField(EditField * f){

   String content = f->GetData();
   f->SetData(ToUpper((String)f->GetData()));
   f->Move(f->GetLength());
}


This code is "activated" setting a callback on the WhenAction method of the control.

I have a couple problem with that.

First of all, maybe already exists some property or function to automatically set uppercase the content of a field, so I can avoid at all that method.

The second problem, is that the method above works well when the user enter the text, but it does not work properly when the user *correct* the text. The problem is in the last line: the cursor is moved to the end, and that is ok when entering the text, but if the user has to correct the text. Let's say the user to change the 3rd letter of the text: he positions the cursor, deletes the third char, but when doing that the callback calls the method, and when the user enters the new char, the cursor has been already moved at the end of the field. I need a way to know the position of the cursor, so I can save it and move the cursor to that position instead of moving it at the end of the line.

How can I fix this?

Regards,
gio
Re: Uppercase in EditField and cursor position [message #52266 is a reply to message #52265] Thu, 22 August 2019 18:58 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Giorgio wrote on Thu, 22 August 2019 12:59
Hi there,
I wrote a method to set uppercase the content of an EditField:

void UppercaseField(EditField * f){

   String content = f->GetData();
   f->SetData(ToUpper((String)f->GetData()));
   f->Move(f->GetLength());
}


This code is "activated" setting a callback on the WhenAction method of the control.

I have a couple problem with that.

First of all, maybe already exists some property or function to automatically set uppercase the content of a field, so I can avoid at all that method.

The second problem, is that the method above works well when the user enter the text, but it does not work properly when the user *correct* the text. The problem is in the last line: the cursor is moved to the end, and that is ok when entering the text, but if the user has to correct the text. Let's say the user to change the 3rd letter of the text: he positions the cursor, deletes the third char, but when doing that the callback calls the method, and when the user enters the new char, the cursor has been already moved at the end of the field. I need a way to know the position of the cursor, so I can save it and move the cursor to that position instead of moving it at the end of the line.

How can I fix this?

Regards,
gio


If all you need is that the text is upercase, then I recommend using SetFilter(CharFilterToUpper).
Re: Uppercase in EditField and cursor position [message #52270 is a reply to message #52266] Fri, 23 August 2019 12:09 Go to previous message
Giorgio is currently offline  Giorgio
Messages: 218
Registered: August 2015
Experienced Member
mirek wrote on Thu, 22 August 2019 18:58
If all you need is that the text is upercase, then I recommend using SetFilter(CharFilterToUpper).


Thanks, it does work, I missed that function.
Previous Topic: Empty DocEdit pre-selecting keypresses (nightly)
Next Topic: Input mask on an EditInt
Goto Forum:
  


Current Time: Thu Mar 28 09:39:32 CET 2024

Total time taken to generate the page: 0.01681 seconds