PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV Mobile 2024 → iOS: How to select all text in a field
iOS: How to select all text in a field
Débuté par Thomas, 07 jan. 2015 12:44 - 3 réponses
Membre enregistré
4 messages
Popularité : +1 (1 vote)
Posté le 07 janvier 2015 - 12:44
I have a GUI which is loaded (with OpenChild) when the user taps on a field on the previous screen (enter field event). On the second GUI there is just one text field visible where the user can enter the quantity for an article.

At the moment if the user needs to change the existing value, he needs to clear first the value and enters the new one using the displayed numerical keyboard.

I would to optimize this. I already tried to set the flags on the text field
--automatic erase
-- with selection in read only

But none of them worked.

Is it somehow possible to call native ObjC code to select all text of that field?
Posté le 07 janvier 2015 - 13:34
Hi Thomas

did you try to play with the ..cursor and ..cursorEnd properties ?

Normally, by setting them to 0 and 1000 in the entry code of the field,
you should have the whole thing selected

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

NEW: WXReplication, your open source replication system is available on
my web site!!!
WXShowroom.com: Show your projects!
More information on http://www.fabriceharari.com


On 1/7/2015 6:44 AM, Thomas wrote:
I have a GUI which is loaded (with OpenChild) when the user taps on a
field on the previous screen (enter field event). On the second GUI
there is just one text field visible where the user can enter the
quantity for an article.
At the moment if the user needs to change the existing value, he needs
to clear first the value and enters the new one using the displayed
numerical keyboard.

I would to optimize this. I already tried to set the flags on the text
field
--automatic erase
-- with selection in read only

But none of them worked.

Is it somehow possible to call native ObjC code to select all text of
that field?
Membre enregistré
4 messages
Popularité : +1 (1 vote)
Posté le 07 janvier 2015 - 14:08
Hi Fabrice

thanks for the hint, but in Version 19 the property Cursor... CursorEnd... is not allowed for iOS.

Maybe this comes with Version 20, when it is available in English too.

In the meanwhile I will use this native iOS solution:

In entry of Field call
selectText(Handle(EDT_EnterText))

which is implemented as ObjC function

#import <UIKit/UIKit.h>

void selectText(void* currentView)
{
UIView *tmpView = (UIView*) currentView;
UITextField *iTextField;
for (id object in [tmpView subviews] ) {
if ( [NSStringFromClass([object class]) isEqualToString: @"CIOSCustomTextField"]) {
iTextField = object;
}
}
[iTextField selectAll:nil];
}

Regards
Thomas
Membre enregistré
3 655 messages
Popularité : +175 (223 votes)
Posté le 10 janvier 2015 - 16:41
:merci: