InputBox with a Number option (type only numbers)

Propose new features and changes
Inspector
Posts: 28
Joined: 29 Jul 2019, 05:17
Contact:

InputBox with a Number option (type only numbers)

30 Aug 2023, 01:01

Hi,

I think it would be cool to have a Number option for a default InputBox, because currently it is available only in Gui.Edit which means one needs to code a customer input box.

I can only assume this wasn't implemented originally is because of the limitation of a windows API?
lexikos
Posts: 9679
Joined: 30 Sep 2013, 04:07
Contact:

Re: InputBox with a Number option (type only numbers)

30 Aug 2023, 02:00

There are probably many options that could have been added to InputBox. As I see it, InputBox is good because it is simple and achieves its purpose in a fairly direct manner, even though it doesn't do anything unique. If we add just anything that could be useful, we then have more redundant code and documentation, and a more complex function.

If you want to fine-tune a dialog box, use Gui.

Personally, I would prefer to have a GUI system that facilitates making input dialog boxes that are scalable, not just a single input field, but without having to micro-manage like with Gui. It's just not a priority for me.
lexikos
Posts: 9679
Joined: 30 Sep 2013, 04:07
Contact:

Re: InputBox with a Number option (type only numbers)

31 Aug 2023, 23:47

Seems that it would be simple to implement, one way or another.

Code: Select all

MsgBox DigitBox("Type a number").Value

DigitBox(Prompt?, Title?, Options?, Default?) {
    static WM_INITDIALOG := 0x0110
    OnMessage WM_INITDIALOG, init
    try
        return InputBox(Prompt?, Title?, Options?, Default?)
    finally
        OnMessage WM_INITDIALOG, init, false
    init(w,l,m, hwnd) {
        static ES_NUMBER := 0x2000
        ControlSetStyle '+' ES_NUMBER, 'Edit1', hwnd
    }
}
There are several other Gui Edit options that could be applicable, but duplicating these options doesn't seem worthwhile as is. The current implementation is not conducive to sharing code between Gui and InputBox. Future revision to the Gui code may reduce the cost of such features.

Return to “Wish List”

Who is online

Users browsing this forum: No registered users and 13 guests