====== jNumpad ======
''jNumpad'' is a composite control of [[.:jbutton|jButtons]] and [[.:jLabel|jLabels]] that can be used to input numeric data.
Although visible in the Visual Studio designer, ''jNumpad'''s ''Visible'' property is ''false'' by default, so it will not display when the form loads on the Windows CE device. Rather, to display the numpad, use the [[.:jnumpad#open_method|Open method]] in response to the operator's input.
===== Properties =====
==== Button Properties ====
Each of the individual buttons are exposed as properties.
{{ .:numpadchildproperties.png?nolink |}}
Because they are exposed as properties their layout, appearance, and behavior can be individually customized.
{{ .:numpadcustomcancelbutton.png?nolink |}}
Or, they can be customized by simply selecting them in the designer.
{{ :jcontrols_cf35:numpadeditbuttons.mp4?854x480 }}
==== ValueDisplay Property ====
The ''ValueDisplay'' property exposes the label that displays the entered value. Like the [[.:jnumpad#button_properties|buttons]], it's layout, appearance, and behavior can be customized.
{{ .:numpadcustomvaluedisplay.png?nolink |}}
==== Text Property ====
The ''Text'' property sets the title of the numpad.
==== Text Features ====
''jNumpad'' employs the same text features used by many of the other controls in the jControls CF35 library including ''ForeColor'', ''TextOffset'', ''TextAlignment'', and ''TextWrap''. See [[.:Text Features]] for more information. These features will affect the title of the numpad.
===== Methods =====
==== Open Method ====
public virtual void Open(Action handleResult, string initialValue, string title, bool clearOnFirstEdit)
public virtual void Open(Action handleResult, string initialValue, string title)
''handleResult'' - The callback to execute when the operator presses the Enter button\\
''initialValue'' - The initial value to display in the numpad's [[.:jnumpad#valuedisplay_property|ValueDisplay property]]\\
''title'' - The text to display as the title of the numpad.\\
''clearOnFirstEdit'' - True to clear the initial value on the first input from the operator, false to immediately append the operators input.\\
The ''Open'' method will display the numpad, and [[https://msdn.microsoft.com/en-us/library/system.windows.forms.control.capture%28v=vs.90%29.aspx|capture the mouse/touch input]] so anywhere outside the numpad will not receive operator input. The //Enter// button will close the numpad and call the ''handleResult'' callback. The //Cancel// button will close the numpad without calling the ''handleResult'' callback.
=== Example ===
The following example has two ''jLabel''s: ''_intLabel'' for integer input and ''_floatLabel'' for floating point input. They will both use the same ''jNumpad'', ''_numpad''. When either label it clicked/touched, their corresponding ''Click'' event handlers will be called, which in turn call ''_numpad'''s ''Open'' method.
After the the operator clicks/touches the //Enter// button to accept input, either the ''SetIntLabel'' method is called to update ''_intLabel'''s value, or the ''SetFloatLabel'' method is called to update ''_floatLabel'''s value.
private void SetIntLabel(string numpadResult)
{
_intLabel.Text = int.Parse(numpadResult).ToString();
// Input is finished, re-enable decimal point
_numpad.DotButton.Enabled = true;
}
private void _intLabel_Click(object sender, EventArgs e)
{
// Disable decimal point for integers
_numpad.DotButton.Enabled = false;
// Open the numpad. Call SetIntLabel when the Enter button is pressed.
_numpad.Open(SetIntLabel, _intLabel.Text, "Integer");
}
private void SetFloatLabel(string numpadResult)
{
_floatLabel.Text = float.Parse(numpadResult).ToString();
}
private void _floatLabel_Click(object sender, EventArgs e)
{
// Open the numpad. Call SetFloatLabel when the Enter button is pressed.
_numpad.Open(SetFloatLabel, _intLabel.Text, "Floating Point");
}
{{ .:numpadopenexample.mp4?854x480 }}