---++!! !CommonCtrl.NumericUpDown %TOC{title="Contents:"}% %STARTINCLUDE% ---++ Represents a Windows spin box (also known as an up-down control) that displays numeric values. | *Title* | Represents a Windows spin box (also known as an up-down control) that displays numeric values. | | *Author(s)* | LiXizhi | | *Date* | | | *File* | script/ide/NumericUpDown.lua | ---+++ Description A NumericUpDown control contains a single numeric value that can be incremented or decremented by clicking the up or down buttons of the control. The user can also enter in a value, unless the ReadOnly property is set to true. The numeric display can be formatted by setting valueformat properties. To specify the allowable range of values for the control, set the Minimum and Maximum properties. Set the Increment value to specify the value to be incremented or decremented to the Value property when the user clicks the up or down arrow buttons. You can increase the speed and Acceleration that the control moves through numbers when the user mouse wheels over the spin box. When the UpButton or DownButton methods are called, either in code or by the click of the up or down buttons, the new value is validated and the control is updated with the new value in the appropriate format. Specifically, if the UserEdit property is set to true, the ParseEditText method is called prior to validating or updating the value. The value is then verified to be between the Minimum and Maximum values, and the UpdateEditText method is called. %T% __Sample Code__ <verbatim> NPL.load("(gl)script/ide/NumericUpDown.lua"); local ctl = CommonCtrl.NumericUpDown:new{ name = "NumericUpDown1", alignment = "_lt", left = 0, top = 0, width = 150, height = 20, parent = nil, value = 50, -- current value valueformat = "%.1f", min = 0, max = 100, min_step = 1, }; ctl:Show(); -- one can also call UpdateUI manually after setting the value property. -- ctl:UpdateUI(); </verbatim> ---+++ Member Functions ---++++ !NumericUpDown:new mouse down position NumericUpDown.lastMouseDown = {x = 0, y=0} NumericUpDown.lastMousePos = {x = 0, y=0} whether any mouse button is down NumericUpDown.IsMouseDown = false; __syntax__ <verbatim>function NumericUpDown:new (o)</verbatim> __parameters__ | *o* | | ---++++ !NumericUpDown:UpdateUI Update UI according to the current value, min, and max. But it does not fire onchage event __syntax__ <verbatim>function NumericUpDown:UpdateUI()</verbatim> ---++++ !NumericUpDown:ValidateData ensure value is in proper range and steps __syntax__ <verbatim>function NumericUpDown:ValidateData()</verbatim> ---++++ !NumericUpDown:SetValue set value, validate it and update UI * _param_ __bFireEvent__ : if true, onchange is event is fired if value is changed. __syntax__ <verbatim>function NumericUpDown:SetValue(value, bFireEvent)</verbatim> __parameters__ | *value* | | | *bFireEvent* | if true, onchange is event is fired if value is changed. | ---++++ !NumericUpDown:GetValue return the correct value __syntax__ <verbatim>function NumericUpDown:GetValue(value)</verbatim> __parameters__ | *value* | | ---++++ !NumericUpDown:UpdateData update date according to a given mouse position. * _param_ __mouse__ :_dy: pixel relative to the mouse down position __syntax__ <verbatim>function NumericUpDown:UpdateData(mouse_dx, mouse_dy)</verbatim> __parameters__ | *mouse* | _dy: pixel relative to the mouse down position | | *dx* | | | *mouse* | _dy: pixel relative to the mouse down position | | *dy* | | ---++++ !NumericUpDown:OnChange called when the check button is pressed. __syntax__ <verbatim>function NumericUpDown:OnChange()</verbatim> %STOPINCLUDE%
E
dit
|
A
ttach
|
P
rint version
|
H
istory
: r1
|
B
acklinks
|
V
iew topic
|
Ra
w
edit
|
M
ore topic actions
Topic revision: r1 - 2008-02-29
-
LiXizhi
Home
Site map
CCWeb web
HaqiTeen web
Main web
ParaEngine web
TWiki web
Main Web
Users
Groups
Index
Search
Changes
Notifications
RSS Feed
Statistics
导航页WebTopMenu
Preferences
开发指南
Getting Started
ParacraftSDK
NPL
MCML
NPL Reference Manual
美术Mod
Account
Log In
English
简体中文
簡體中文
E
dit
A
ttach
Copyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback