Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add combobox to Windows #61

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Phillips126
Copy link
Contributor

Here is an implementation of a combobox feature for NiGui (Windows only).

Comboboxes can have several styles: CBS_SIMPLE, CBS_DROPDOWN, or CBS_DROPDOWNLIST so I included a way to pass the desired type when creating the combobox. Possible values are: simple (default), dropdown, dropdownlist. Leaving this unspecified will default to CBS_SIMPLE

Creating a combobox:
var combobox = newComboBox(@["Choice 1", "Choice 2"], "dropdown")
var combobox2 = newComboBox() (will create empty combobox)

I've created a few methods as well for combobox interactions:

  • getOptionCount(): returns number of options currently available in dropdown
  • addOption(<string>): adds a new option to bottom of dropdown
  • deleteOption(<int>): deletes option from list at index specified
  • selectOption(<int>): selects option at index
  • findOptionIndex(<string>): searches list of options, returns index or -1 (not found)
  • getSelectedIndex(): returns the index of the selected option (-1 if none selected)
  • getSelectedValue(): returns the value of the selected option ("" if none selected)

The natualHeight probably needs work. I am not sure how to best size the CBS_SIMPLE combobox. The getTextLineHeight() appears to be different for the selected value box and each of the dropdown items.

Again, I am new to Nim and have never done any Win32 development until last week so I am not sure if everything is done properly but this should hopefully help you roll out this in a future release.

@Phillips126 Phillips126 changed the title Add combobox Add combobox to Windows Sep 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant