Pressing divide numpad key after pressing a letter behaves differently when it is pressed after a number? - textbox

I am developing a WPF application for arabic users using vb .net.
In the application the user has to enter in a textbox the following: "22/85/39" but unfortunately after entering it, it displays the reverse (i.e. 39/85/22).
This is my xaml code:
<TextBox x:Name="txtWorkingNumber" Height="26" VerticalAlignment="Center" HorizontalAlignment="Left" Width="200"
Text="{Binding WorkingNumber}"
FlowDirection="RightToLeft"
Language="ar-SA"
NumberSubstitution.Substitution="AsCulture"/>
I have tried all Substitution enumerations but failed to find the fix.
Could any one give me a help on how to fix it??
many thanx...

Finally I found the solution which is, to add white space at the end of the text where you type "/" sympole. This is achieved through this code snippet added to the code behind:
Private Sub TextBox_PreviewKeyDown(sender As Object, e As System.Windows.Input.KeyEventArgs)
Dim myTextBox As TextBox = CType(sender, TextBox)
If Thread.CurrentThread.CurrentCulture.ToString.StartsWith("ar") Then
If e.Key = System.Windows.Input.Key.Divide Then
myTextBox.Text += " "
myTextBox.CaretIndex = myTextBox.Text.Length
End If
End If
End Sub

Related

ProFormFieldSet affecting ProFormText addonBefore attribute text to disappear?

I am trying to add some text before each Proformtext component, but it is not appearing
Below is my code
<ProFormFieldSet
name="firstrow"
label={<span style={{fontSize: fontSize}}>A</span>}
labelAlign={labelAlignment}
>
<ProFormText
addonBefore="helloworld"
labelAlign={labelAlignment}
width="md"
/>
=
<ProFormText
addonBefore={C}
width="md" />
</ProFormFieldSet>
This is the Actual result
Expected Result
There is text beside each input.
What I have tried
I took ProFormText component out from ProFormFieldSet and the text appear. anyone know why this is happening??
according to the reference, the props we set for ProFormText are actually for Form.Item, and the fieldProps are for the included Input, remember. pro-form-fields-reference
have a try like below
<ProFormFieldSet
name="firstrow"
label={<span style={{fontSize: fontSize}}>A</span>}
labelAlign={labelAlignment}
>
<ProFormText
fieldProps={{addonBefore:"helloworld"}}
labelAlign={labelAlignment}
width="md"
/>
=
<ProFormText
fieldProps={{addonBefore: C}}
width="md" />
</ProFormFieldSet>

is it possible to allow spaces in "number" input angularjs

I am making an app using ionic framework -v1, now i found out when deploying my app to IOS the app seems to works perfectly fine at first.
But when i enter a space (using the mobile number keypad) in my input=[number] field the app starts flickering and loses the scopes with the space in them. Later when i want to push my data to angularfire it also completely stops working and wont let me push my data.
My input is as simple as this:
<input type="number" name="" ng-model="info.DriversLicensenr">
My customer would like the field to have spaces in them, but also the numbers keypad should show up when pressed in the app.
Is there any way to allow spaces? or to modify another input type to reach the desired effect?
This kind of input will open a number pad on mobile device. However, you will have to check that the user doesn't type other caracters than numbers.
<input type="text" inputmode="numeric" ng-model="ctrl.dLicence"/>
EDIT
<input type="text" pattern="[0-9\s]*"/>
This opens a number pad, but doesn't limit to numbers only.
No that's not possible i will suggest you to use input type text and then use ng-pattern to validate it is number or not. This won't stop you from inserting characters but will show error it there's a character or any other special characters.
To restrict input to only numbers or space , use below code
<input type="text" inputmode="numeric" oninput="formatNumber(event)"/>
function formatNumber(event){
let value = event.target.value || '';
value = value.replace(/[^0-9 ]/,'');
event.target.value = value;
}

Is there material input type number in angular 2 dart

I was tring to use material component in angular 2 dart as a number input:
<material-input type="number"></material-input>
but it behaves like a normal input. In docs it sais it supports type "number". Am i doing anything wrong? Or isn't number type implemented yet?
Thank you for any suggestions.
I can share my personal experiment trying to have a number (integer) input. It does not work perfectly on all browsers but I wanted to have the proper keyboard shown on Android and iOS. What I did was forcing the type on the inner input element programmatically. It seems that on Firefox it does not prevent entering text but does display a message ("Please enter a number"). It does not handle decimal neither (i.e. it does expect an integer)
initInputNumber(MaterialInputComponent inputComponent) {
inputComponent.type = "number";
InputElement inputElement = inputComponent.inputEl.nativeElement;
inputElement.type = "number";
// http://stackoverflow.com/questions/6178556/phone-numeric-keyboard-for-text-input
// As of mid-2015, I believe this is the best solution:
// <input type="number" pattern="[0-9]*" inputmode="numeric">
inputElement.attributes["inputmode"] = "numeric";
inputElement.pattern = "[0-9]*"; // this and only this works 0-9
}
I don't know if that's the best solution but I find it hard to have a complete cross-browser solution
I think you need to set an errorMsg
<material-input type="number" errorMsg="That's not a number"></material-input>
This line https://github.com/dart-lang/angular2_components/blob/a0eff879a6cb347b8beb95ed758c02c6dd9dfaa0/lib/src/components/material_input/material_input.dart#L232 seems to indicate that type="tel" and type="number" are set to text for the internal input element, while this line https://github.com/dart-lang/angular2_components/blob/a0eff879a6cb347b8beb95ed758c02c6dd9dfaa0/lib/src/components/material_input/material_input.dart#L61 says that errorMsg is used when and invalid number is entered when type="number".

Dynamically change textbox to multiline

I am working on a Firefox extension. I have a simple single-line textbox. When a user pastes in text, I want to detect if the text has newlines and if it does, I want to expand the textbox into a multiline textbox.
I have
<textbox id="textbox" rows="5" wrap="off" newlines="pasteintact" oninput="adjustTextbox(this)" flex="1"/>
and on the JS side, I have
adjustTextbox(txtBox) {
if(!txtBox.getAttribute('multiline') && txtBox.value.match(/[\r\n]/)) {
txtBox.setAttribute('multiline', true);
}
}
The problem is that, while the textbox does get converted to a 5 row multiline textbox, the value that is pasted in is lost and the textbox is blank. Am I doing something wrong here?
Short answer: no, you aren't doing anything wrong, the value is expected to be cleared when you switch from single-line to multi-line. Long answer: the <textbox> element doesn't actually hold the value itself, it rather contains an anonymous <html:input type="text>. When you add the multiline attribute a different XBL binding applies to the element and that anonymous text field is replaced by <html:textarea>. Obviously, the value gets lost in the process.
You could try to save the value and to restore it after you add the multiline attribute. The problem is that it is hard to tell when the binding actually applies, there is a delay that is not really predictable. So the better solution would be to have both a single-line and a multi-line text box in your document and make sure that one of them is always collapsed:
<textbox id="textbox" newlines="pasteintact" oninput="adjustTextbox(this)" flex="1"/>
<textbox id="textbox2" collapsed="true" multiline="true" rows="5" wrap="off" flex="1"/>
And on the JavaScript side:
function adjustTextbox(txtBox) {
if(!txtBox.getAttribute('multiline') && txtBox.value.match(/[\r\n]/)) {
var txtBox2 = document.getElementById("textbox2");
txtBox2.value = txtBox.value;
txtBox.collapsed = true;
txtBox2.collapsed = false;
}
}

WPF TextBox.SelectAll () doesn't work

I have used the following template in my project:
<DataTemplate
x:Key="textBoxDataTemplate">
<TextBox
Name="textBox"
ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}"
Tag="{Binding}"
PreviewKeyDown="cellValueTextBoxKeyDown">
<TextBox.Text>
<MultiBinding
Converter="{StaticResource intToStringMultiConverter}">
<Binding
Path="CellValue"
Mode="TwoWay">
<Binding.ValidationRules>
<y:MatrixCellValueRule
MaxValue="200" />
</Binding.ValidationRules>
</Binding>
<Binding
RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type y:MatrixGrid}}"
Path="Tag"
Mode="OneWay" />
</MultiBinding>
</TextBox.Text>
</TextBox>
</DataTemplate>
I used this template to create an editable matrix for the user. The user is able to navigate from cell to cell within the matrix and I would like to highlight the data in the selected textbox but it doesn't work. I called TextBox.Focus () and TextBox.SelectAll () to achieve the effect but nothing. The Focus () works but the text never gets highlighted.
Any help is welcome and appreciated.
Okay, if anyone is interested, the solution to this problem of mine was to include the statement e.Handled = true; in the event handler method where the textBox.SelectAll() and textBox.Focus() are called.
The problem was that I attached an event handler to the textbox's PreviewKeyDown event which handles a tunneling event and probably the SelectAll() and Focus() calls are ignored without calling the e.Handled = true; statement.
Hope it'll help someone.
Without the rest of your code it's difficult to say whether this will work for you, but I put together a small sample using your DataTemplate (minus the parts that refer to code that wasn't posted).
I was able to select all the text in the text boxes by adding a GotFocus event handler to the TextBox in the DataTemplate:
<TextBox
...
GotFocus="textBox_GotFocus"
...>
...
</TextBox>
And the code-behind:
private void textBox_GotFocus(object sender, RoutedEventArgs e)
{
TextBox textBox = sender as TextBox;
if (textBox != null)
{
textBox.SelectAll();
}
}
Let me know if you are attempting to select all under different circumstances (not when the box receives focus).
Here's a very good very simple solution (I don't know if it works for your template, but give it a try): http://social.msdn.microsoft.com/forums/en-US/wpf/thread/564b5731-af8a-49bf-b297-6d179615819f

Resources