Reputation: 1569
I am creating windows phone 8.1 app using javascript and i created a custom keyboard for my app but when ever i click on input/text fields windows phone keyboard pops up. I want to disable it for my app only.
I did something this
<body id="body">
<textarea id="input" onclick="loseFocus()"></textarea>
<script>
function loseFocus(){
document.getelementById("body").focus();
}
</script>
</body>
But its not working as i want.. as it loses focus it losses blinking cursor and not able to write in textarea
Update I thought to do it in a new way. I am using iframe instead of textarea and to edit iframe or input text in it i am using innerHTML property
and an onClick event pops up my custom keyboard now the problem is I want blinking cursor in iframe where ever i'm working in it
Upvotes: 1
Views: 1067
Reputation: 11595
I ran into a similar problem.
My workaround was to create a textblock under the textbox and have it share the textbox's content. I then toggle visibility states between the two to prevent the keyboard from displaying when it's not required.
It's a hack but it worked for my situation.
Upvotes: 0
Reputation: 2621
You can do it with Update content of text area at interval of 1 Second. Append/remove |
Character at interval of Second.
setTimeout(function() {UpdateContent()}, 1000);
Upvotes: 1
Reputation: 9857
The problem that you run into is that the TextBox control on focus event is intercepted by the phone itself and it brings the keyboard up.
In short, there is NO way around this functionality. However, there is an alternative method.
Build your own textbox control.... This sounds crazy at first but is it? Not really. I build custom controls all the time at work. Granted usually they're a combination of other pre-made controls, but they are UserControls none the less.
So lets think about this, how to make your own?
I am not sure if you are able to use XAML elements in your project or not. However, if you are here is how to do it with a user control. Otherwise you will need to research how to make custom web controls. Likely a mix of CSS and HTML
Start with something simple like this
<Grid> <--- Handle your tap event
<Border>
<TextBlock> <-- Databind this to a string property in your back end code
Have your grid handle your tap event.
Think of XAML
as an upsidown cake. When you tap the Textblock
, if the tap isn't handled it goes onto the boarder, then the grid. So if you have your grid handle the tap it will consume the inner taps as well.
So what do you do on your tap event?
Well here is where you would present your custom keyboard. You're going to want to identify which custom TextBlock was tapped on. You could probably do this by putting a custom tag on each.
As your user types on the custom keyboard, change the property value that the TextBlock is bound too. This will update the text on the screen.
That's pretty much a basic textblock.
Here are the assumptions to take from this post:
You know what a user control is
You know how to DataBind
You know about 2 way DataBinding
Hope this helps!
Upvotes: 2