number textbox with predefined values

3 views
Skip to first unread message

Pavel Krivanek

unread,
Dec 16, 2010, 8:59:03 AM12/16/10
to xul...@googlegroups.com
Hi,

if you have a textbox for number input and you want to offer several
values, you may use an editable menulist but in this case the user can
add a general string value and you have to validate the input.

This is a code that shows a number input with predefined values. I
assume that I will add something like that directly to xuljet
(probably the possibility to add a popoup with predefined values to
any kind of input element)

// register only one closure for all popup items
var setValue = this.$C(function(self) {this.postageTextBox.value =
self.getAttribute('xuljet:value')});
with (xul)
{
hbox({align: "stretch"},
textbox({bind: "postageTextBox", type: "number", decimalplaces: 2,
style: 'margin-right: 0px; width:6em'}),
caption({align: "center", maxwidth: "10px", label: "▼", style:
'margin-left: 0px; width:2em', onclick: function() {
this.postagePopup.openPopup(this.postageTextBox)
}}))
popupset(
menupopup({bind: "postagePopup" , position: "after_start" },
menuitem({label: "Value 1 (10.5)", 'xuljet:value': 10.50,
oncommand: setValue}),
menuitem({label: "Value 2 (20)", 'xuljet:value': 20,
oncommand: setValue})))
}

Cheers
-- Pavel

textbox.png
Reply all
Reply to author
Forward
0 new messages