GithubHelp home page GithubHelp logo

Comments (9)

eleriaqueen avatar eleriaqueen commented on June 27, 2024

Nuklear seems to have many tools for combo boxes, but what do you mean by selecting multiple options ?
As far as I know combo boxes usually have only one selected option.

/* =============================================================================
 *
 *                                  COMBOBOX
 *
 * ============================================================================= */
NK_API int nk_combo(struct nk_context*, const char **items, int count, int selected, int item_height, struct nk_vec2 size);
NK_API int nk_combo_separator(struct nk_context*, const char *items_separated_by_separator, int separator, int selected, int count, int item_height, struct nk_vec2 size);
NK_API int nk_combo_string(struct nk_context*, const char *items_separated_by_zeros, int selected, int count, int item_height, struct nk_vec2 size);
NK_API int nk_combo_callback(struct nk_context*, void(*item_getter)(void*, int, const char**), void *userdata, int selected, int count, int item_height, struct nk_vec2 size);
NK_API void nk_combobox(struct nk_context*, const char **items, int count, int *selected, int item_height, struct nk_vec2 size);
NK_API void nk_combobox_string(struct nk_context*, const char *items_separated_by_zeros, int *selected, int count, int item_height, struct nk_vec2 size);
NK_API void nk_combobox_separator(struct nk_context*, const char *items_separated_by_separator, int separator, int *selected, int count, int item_height, struct nk_vec2 size);
NK_API void nk_combobox_callback(struct nk_context*, void(*item_getter)(void*, int, const char**), void*, int *selected, int count, int item_height, struct nk_vec2 size);
/* =============================================================================
 *
 *                                  ABSTRACT COMBOBOX
 *
 * ============================================================================= */
NK_API nk_bool nk_combo_begin_text(struct nk_context*, const char *selected, int, struct nk_vec2 size);
NK_API nk_bool nk_combo_begin_label(struct nk_context*, const char *selected, struct nk_vec2 size);
NK_API nk_bool nk_combo_begin_color(struct nk_context*, struct nk_color color, struct nk_vec2 size);
NK_API nk_bool nk_combo_begin_symbol(struct nk_context*,  enum nk_symbol_type,  struct nk_vec2 size);
NK_API nk_bool nk_combo_begin_symbol_label(struct nk_context*, const char *selected, enum nk_symbol_type, struct nk_vec2 size);
NK_API nk_bool nk_combo_begin_symbol_text(struct nk_context*, const char *selected, int, enum nk_symbol_type, struct nk_vec2 size);
NK_API nk_bool nk_combo_begin_image(struct nk_context*, struct nk_image img,  struct nk_vec2 size);
NK_API nk_bool nk_combo_begin_image_label(struct nk_context*, const char *selected, struct nk_image, struct nk_vec2 size);
NK_API nk_bool nk_combo_begin_image_text(struct nk_context*,  const char *selected, int, struct nk_image, struct nk_vec2 size);
NK_API nk_bool nk_combo_item_label(struct nk_context*, const char*, nk_flags alignment);
NK_API nk_bool nk_combo_item_text(struct nk_context*, const char*,int, nk_flags alignment);
NK_API nk_bool nk_combo_item_image_label(struct nk_context*, struct nk_image, const char*, nk_flags alignment);
NK_API nk_bool nk_combo_item_image_text(struct nk_context*, struct nk_image, const char*, int,nk_flags alignment);
NK_API nk_bool nk_combo_item_symbol_label(struct nk_context*, enum nk_symbol_type, const char*, nk_flags alignment);
NK_API nk_bool nk_combo_item_symbol_text(struct nk_context*, enum nk_symbol_type, const char*, int, nk_flags alignment);
NK_API void nk_combo_close(struct nk_context*);
NK_API void nk_combo_end(struct nk_context*);

from nuklear.

8dcc avatar 8dcc commented on June 27, 2024

Well, I think my example was pretty clear. Normally with a combobox you select an option, and it changes the value of the selected pointer to the index of the item you just selected:

char* opts[] = {
    "opt0",
    "opt1",
    "opt2",  /* If you click this, the value of the pointer is set to 2 */
    "opt3",
};

However, what I want is being able to select more than one option, so in the above example I might want to select "opt2" and "opt3". Storing multiple selections with just a int* is not possible, and that's why I posted that pseudo-code in my first comment.

Maybe this image can help you understand what I mean, although I have no idea where this is from:

image

In that example I would want to select more than one option. Obviously, ignore the typing part and the visual checkbox.

from nuklear.

quadroli avatar quadroli commented on June 27, 2024

Hello @8dcc I am unaware whether Nuklear has such a widget.. But, how about using multiple nk_checkbox_label() widgets nested in a nk_tree_push()? From my pov it'll kinda have the same effect..

from nuklear.

8dcc avatar 8dcc commented on June 27, 2024

Hello @quadroli, although that's the functionality I was looking for, it's not exactly how I expect it to look.

I found an example in a (pretty funny) YouTube video from a very loud and aggressive person: Link.

from nuklear.

SwooshyCueb avatar SwooshyCueb commented on June 27, 2024

IMO for this kind of thing you're going to want the checkboxes like in @8dcc's comment, as they very clearly convey that the user can make multiple selections. Without them, it is not made clear to the user that multiple selections are possible.

from nuklear.

8dcc avatar 8dcc commented on June 27, 2024

IMO for this kind of thing you're going to want the checkboxes like in @8dcc's comment, as they very clearly convey that the user can make multiple selections. Without them, it is not made clear to the user that multiple selections are possible.

Well, showing which selections are enabled to the user should be pretty easy, just change the background color of the selected options just like it's done currently with a combobox.

Although I do understand what you mean, initially there would be no obvious visual difference between a normal and a multiple option combobox. In my case that does not matter since the context would make that obvious, but I get that the changes need to be more general.

from nuklear.

r4klatif avatar r4klatif commented on June 27, 2024

just wrap ordinary calls to nk_checkbox_label() between nk_combo_begin_label() and nk_combo_end()
e.g.

if(nk_combo_begin_label(ctx, "Dropdown", nk_vec2(200, 200)))
{
	nk_layout_row_dynamic(ctx, 0, 1);
	nk_checkbox_label(ctx, "Option A", &a);
	nk_checkbox_label(ctx, "Option B", &b);
	nk_combo_end(ctx);
}

beware, you can't stack multiple comboboxes inside of eachother because of the way 'nuklear windows' work.

from nuklear.

8dcc avatar 8dcc commented on June 27, 2024

I guess this will have to do.

from nuklear.

8dcc avatar 8dcc commented on June 27, 2024

Instead of nk_checkbox_label, I think nk_selectable_label is what I was looking for.

from nuklear.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.