iOS Question Textfield : Right to Left ?

tufanv

Expert
Licensed User
Longtime User
Hello

is it possible to input the text from right to left instead of default left to right ?

TY
 

tufanv

Expert
Licensed User
Longtime User
I dont know if I understood your question correctly but try this

Dim a As TextField
a.TextAlignment=a.ALIGNMENT_RIGHT

narek

Ty for answer. I mean if i input 5281 I want textfield to show 1825 also ( i figured out how to align right with your answer ty )
 
Upvote 0

narek adonts

Well-Known Member
Licensed User
Longtime User
NOT TESTED

try this.

B4X:
Sub myTextView_TextChanged (OldText As String, NewText As String)
dim no as NativeObject = Me  
no.RunMethod("SetToRight:",Array(myTextView))

End Sub

#If OBJC

-(void) SetToRight: (UITextField *)myTextField
{
[myTextField setBaseWritingDirection:UITextWritingDirectionRightToLeft forRange:[myTextField textRangeFromPosition:[myTextField beginningOfDocument] toPosition:[myTextField endOfDocument]]];
}


#End if

I recommend to put Dim no as NativeObject = me in Process_Globals
 
Last edited:
Upvote 0

tufanv

Expert
Licensed User
Longtime User
NOT TESTED

try this.

B4X:
Sub myTextView_TextChanged (OldText As String, NewText As String)
dim no as NativeObject = Me 
no.RunMethod("SetToRight:",Array(myTextView))

End Sub

#If OBJC

-(void) SetToRight: (UITextField *)myTextField
{
[myTextField setBaseWritingDirection:UITextWritingDirectionRightToLeft forRange:[myTextField textRangeFromPosition:[myTextField beginningOfDocument] toPosition:[myTextField endOfDocument]]];
}


#End if

I recommend to put Dim no as NativeObject = me in Process_Globals
will try and report back Thank you !
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User
NOT TESTED

try this.

B4X:
Sub myTextView_TextChanged (OldText As String, NewText As String)
dim no as NativeObject = Me 
no.RunMethod("SetToRight:",Array(myTextView))

End Sub

#If OBJC

-(void) SetToRight: (UITextField *)myTextField
{
[myTextField setBaseWritingDirection:UITextWritingDirectionRightToLeft forRange:[myTextField textRangeFromPosition:[myTextField beginningOfDocument] toPosition:[myTextField endOfDocument]]];
}


#End if

I recommend to put Dim no as NativeObject = me in Process_Globals

I tried it now . it makes the textfield start from right ty but i also need this: when i write hello it rights hello at the right but i want it to write reverse : olleh from rgiht to left is it also possible ?
 
Upvote 0
Top