simonkrauter / NiGui

Cross-platform desktop GUI toolkit written in Nim
MIT License
718 stars 50 forks source link

How to use controls such as select list,checkbox,radio? #18

Open shawnye opened 6 years ago

shawnye commented 6 years ago

Thank you for nice work! That's what I want.

How to use controls such as select list,checkbox,radio?

BTW, how to add address bar when open dialog?

Thank you!

simonkrauter commented 6 years ago

The project is in a very early stage. It first needs more developers and then decisions how to go forward. I think before implementing more controls, the general concept should be finished and documented. If there is any interested developer (especially on macOS), please contact me.

enthus1ast commented 6 years ago

Dankr4d is working on these: https://github.com/Dankr4d/nigui/tree/widgets

shawnye commented 6 years ago

@enthus1ast thank you! I will try it

gogolxdong commented 4 years ago

Is checkbox usable on Windows since nim v1.0? found NativeCheckbox* = ref object of Checkbox seems incomplete. What to do if I try to finish this?

simonkrauter commented 4 years ago

I have implemented checkboxes here recently, no known issues. Yes, NiGui works with Nim 1.0. Other widgets will follow at some time.

cn-care commented 4 years ago

Great, probably

var checkbox = newCheckbox("Checkbox")
checkbox.init()
checkbox.text = "Checkbox"
container.add(checkbox)

helps to see how checkbox works in exmpale_02_controls.nim

simonkrauter commented 4 years ago

@cn-care: example_02_controls.nim already contains a checkbox. In your code example, you should not call init(), because it's called automatically in newCheckbox().

qqtop commented 4 years ago

May be add this to the example_02_controls.nim

    # Add a further Checkbox control:
    var checkbox2 = newCheckbox("Checkbox2")
    container.add(checkbox2)

   # Add toggle event to the checkbox
    checkbox.onToggle = proc(event: ToggleEvent) =
      case  checkbox.checked
        of true:  textArea.addLine("Checkbox was checked")  
        of false: textArea.addLine("Checkbox was unchecked")

    # Add toggle event to the checkbox2 to enable/disable checkbox
    checkbox2.onToggle = proc(event: ToggleEvent) =
      case  checkbox.enabled
        of true:
                  checkbox.enabled = false 
                  textArea.addLine("Checkbox was disabled")  
        of false:
                  checkbox.enabled = true  
                  textArea.addLine("Checkbox was enabled")