Comments (9)
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.
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:
In that example I would want to select more than one option. Obviously, ignore the typing part and the visual checkbox.
from nuklear.
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.
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.
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.
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.
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.
I guess this will have to do.
from nuklear.
Instead of nk_checkbox_label
, I think nk_selectable_label
is what I was looking for.
from nuklear.
Related Issues (20)
- Using SDL_GetWindowBordersSize() messes up everything. HOT 3
- Line chart performance: boxes on points make line charts much slower than without HOT 1
- Is it possible to know whether input is captured?
- Creating a nk_image with the sdl_renderer backend HOT 2
- Errors in compiling https://immediate-mode-ui.github.io/Nuklear/doc/#nuklear/example
- Two Issues with Fonts
- Inconsistent grabbing behavior in demos (click and drag property) HOT 8
- Build help with Allegro5 MinGW-64(TDM-Posix-SEH) HOT 2
- Demo headers and nk_ and design choices, oh my! HOT 6
- Backspace does not actually clear a buffer when using nk_edit_string HOT 4
- File Menu HOT 6
- Request: create example for showcasing integration with RGFW HOT 2
- How to make own title bar, without using the operating systems HOT 3
- Group margins/alignment Ubuntu HOT 3
- Demo doesn't include code on how to display images without OpenGL. HOT 1
- After set an opened Combo Box to invisible, no response from the entire window.
- How to do multiple render with one update HOT 2
- Events not working with multiple Nuklear windows
- Add `delta_time_seconds` to each renderer
- GUI "cards" HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nuklear.