Hello,
I'm looking for an option to set the cursor position at the end of initial text (I set it with Setter(RadTextBox.TextProperty). Is it possible? I know that the user can click at the end, but it would be a nice feature.
Taking an opportunity I will ask also if there is a possibility to show inputprompt without any button? The user will confirm only with keyDownHandler.
Thank you,
Tomasz
6 Answers, 1 is accepted
Thank you for contacting us. Could you please send us a sample project demonstrating what you're trying to achieve? This way we would be able to assist you better.
Regards,
Kiril Stanoev
Telerik
Hello Kiril and thank you for reply.
Here is sample code:
Style titleStyle.Setters.Add(
new
Setter(RadTextBox.TextProperty,
"Sample Title"
));
InputPromptClosedEventArgs result = await RadInputPrompt.ShowAsync(
new
string
[] {
"Yes"
,
"No"
}, title:
"Enter title"
,
message:
"Please enter a title:"
, isCheckBoxChecked:
true
, checkBoxContent:
null
, inputMode: InputMode.Text,
inputStyle: titleStyle, vibrate:
false
, horizontalAlignment: System.Windows.HorizontalAlignment.Stretch,
verticalAlignment: System.Windows.VerticalAlignment.Top,
keyDownHandler: (keyArgs) => {
if
(keyArgs.Key == Key.Enter) RadInputPrompt.Close(0); });
Normally in TextBox as I remember we can use Select to achieve that.
The Second question is if I can make this promptBox above without any button (Ok) - the user will accept with key.Enter and cancel with back button.
Thank you for the clarification. Unfortunately there's no easy way to achieve what you're looking for. One suggestion though. Would it help your scenario if you set a Watermark instead of a Text:
titleStyle.Setters.Add(
new
Setter(RadTextBox.WatermarkProperty,
"Sample Title"
));
...or you insist of using the Text property?
Let me know what you think. I'd be glad to assist you further.
Regards,
Kiril Stanoev
Telerik
Hi Kiril,
Unforutunately watermark won't be sufficient because when you receive args at the return, with watermark if user entered nothing, you get null or "" and with textProperty you get the text you provided. For example imagine, that I've user name and I want him to add his age at the end in the prompt box. Ok, It would be nice, but it's not so important. Think about providing a method to set a cursor position, it shouldn't be hard for you to implement such a one.
The second problem (with no buton) I've managed to solve myself.
There is also a thing you can improve - In the code above when I hit enter, the box closes, but the keyboard remains on the screen for a while. Is there a code which I should add to replicate the exact behaviour of clicking "yes" button in prompt box - close keyboard, bring page to front (it's a little darker for a while)? I manager to get rid off the keyboard with this.Focus() but I still don't know how the darkening is realized.
Thank you, Tomasz
To workaround the cursor issue, please refer to the attached project.
As for your second question, I was unable to reproduce the issue. The keyboard always hid whenever I pressed Enter. Please take a look at this video and let me know if I am missing anything.
Regards,
Kiril Stanoev
Telerik
Hello Kiril,
Thank you very much for the provided code - works perfect and it helps me a lot.
As for the second issue, I've tried to reproduce the situation on your code, but I've failed - which means that I've probably screwed something up in my code. I'll check it, and if I'm able to reproduce the situation I'll provide that code.
Regards,
Tomasz