Add method for removing ComboBox item
void uiComboboxDelete(uiCombobox *c, int n) * Unix: gtk_combo_box_text_remove * Windows: CB_DELETESTRING * Darwin: NSPopUpButton.removeItemAtIndex
This commit is contained in:
parent
17486fd175
commit
d4ecc16dd7
|
@ -81,6 +81,11 @@ void uiComboboxAppend(uiCombobox *c, const char *text)
|
||||||
[c->pbac addObject:uiprivToNSString(text)];
|
[c->pbac addObject:uiprivToNSString(text)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void uiComboboxDelete(uiCombobox *c, int n)
|
||||||
|
{
|
||||||
|
[c->pb removeItemAtIndex:n];
|
||||||
|
}
|
||||||
|
|
||||||
int uiComboboxSelected(uiCombobox *c)
|
int uiComboboxSelected(uiCombobox *c)
|
||||||
{
|
{
|
||||||
return [c->pb indexOfSelectedItem];
|
return [c->pb indexOfSelectedItem];
|
||||||
|
|
|
@ -39,6 +39,11 @@ static void appendCBRB(uiButton *b, void *data)
|
||||||
uiRadioButtonsAppend(rb, "New Item");
|
uiRadioButtonsAppend(rb, "New Item");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void deleteCB(uiButton *b, void *data)
|
||||||
|
{
|
||||||
|
uiComboboxDelete(cbox, 0);
|
||||||
|
}
|
||||||
|
|
||||||
static void onCBChanged(uiCombobox *c, void *data)
|
static void onCBChanged(uiCombobox *c, void *data)
|
||||||
{
|
{
|
||||||
printf("%s combobox changed to %d\n",
|
printf("%s combobox changed to %d\n",
|
||||||
|
@ -147,6 +152,9 @@ uiBox *makePage4(void)
|
||||||
b = uiNewButton("Append");
|
b = uiNewButton("Append");
|
||||||
uiButtonOnClicked(b, appendCBRB, NULL);
|
uiButtonOnClicked(b, appendCBRB, NULL);
|
||||||
uiBoxAppend(hbox, uiControl(b), 0);
|
uiBoxAppend(hbox, uiControl(b), 0);
|
||||||
|
b = uiNewButton("Delete");
|
||||||
|
uiButtonOnClicked(b, deleteCB, NULL);
|
||||||
|
uiBoxAppend(hbox, uiControl(b), 0);
|
||||||
b = uiNewButton("Second");
|
b = uiNewButton("Second");
|
||||||
uiButtonOnClicked(b, selectSecond, NULL);
|
uiButtonOnClicked(b, selectSecond, NULL);
|
||||||
uiBoxAppend(hbox, uiControl(b), 0);
|
uiBoxAppend(hbox, uiControl(b), 0);
|
||||||
|
|
1
ui.h
1
ui.h
|
@ -226,6 +226,7 @@ _UI_EXTERN uiSeparator *uiNewVerticalSeparator(void);
|
||||||
typedef struct uiCombobox uiCombobox;
|
typedef struct uiCombobox uiCombobox;
|
||||||
#define uiCombobox(this) ((uiCombobox *) (this))
|
#define uiCombobox(this) ((uiCombobox *) (this))
|
||||||
_UI_EXTERN void uiComboboxAppend(uiCombobox *c, const char *text);
|
_UI_EXTERN void uiComboboxAppend(uiCombobox *c, const char *text);
|
||||||
|
_UI_EXTERN void uiComboboxDelete(uiCombobox *c, int n);
|
||||||
_UI_EXTERN int uiComboboxSelected(uiCombobox *c);
|
_UI_EXTERN int uiComboboxSelected(uiCombobox *c);
|
||||||
_UI_EXTERN void uiComboboxSetSelected(uiCombobox *c, int n);
|
_UI_EXTERN void uiComboboxSetSelected(uiCombobox *c, int n);
|
||||||
_UI_EXTERN void uiComboboxOnSelected(uiCombobox *c, void (*f)(uiCombobox *c, void *data), void *data);
|
_UI_EXTERN void uiComboboxOnSelected(uiCombobox *c, void (*f)(uiCombobox *c, void *data), void *data);
|
||||||
|
|
|
@ -30,6 +30,11 @@ void uiComboboxAppend(uiCombobox *c, const char *text)
|
||||||
gtk_combo_box_text_append(c->comboboxText, NULL, text);
|
gtk_combo_box_text_append(c->comboboxText, NULL, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void uiComboboxDelete(uiCombobox *c, int n)
|
||||||
|
{
|
||||||
|
gtk_combo_box_text_remove(c->comboboxText, n);
|
||||||
|
}
|
||||||
|
|
||||||
int uiComboboxSelected(uiCombobox *c)
|
int uiComboboxSelected(uiCombobox *c)
|
||||||
{
|
{
|
||||||
return gtk_combo_box_get_active(c->combobox);
|
return gtk_combo_box_get_active(c->combobox);
|
||||||
|
|
|
@ -69,6 +69,15 @@ void uiComboboxAppend(uiCombobox *c, const char *text)
|
||||||
uiprivFree(wtext);
|
uiprivFree(wtext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void uiComboboxDelete(uiCombobox *c, int n)
|
||||||
|
{
|
||||||
|
LRESULT res;
|
||||||
|
|
||||||
|
res = SendMessage(c->hwnd, CB_DELETESTRING, (WPARAM)n, 0);
|
||||||
|
if (res == (LRESULT) CB_ERR)
|
||||||
|
logLastError(L"error removing item from uiCombobox");
|
||||||
|
}
|
||||||
|
|
||||||
int uiComboboxSelected(uiCombobox *c)
|
int uiComboboxSelected(uiCombobox *c)
|
||||||
{
|
{
|
||||||
LRESULT n;
|
LRESULT n;
|
||||||
|
|
Loading…
Reference in New Issue