int nitems = RARRAY_LEN(items);
int idx = RubyDialogCallback_indexOfItem(dref, ip);
static VALUE sTextActionSym = Qfalse, sEscapeActionSym, sReturnActionSym;
+ VALUE retval;
if (sTextActionSym == Qfalse) {
sTextActionSym = ID2SYM(rb_intern("text_action"));
}
/* If the item has the "action" attribute, call it */
+ retval = Qtrue;
actval = s_RubyDialogItem_Attr(itval, aval);
if (actval != Qnil) {
if (TYPE(actval) == T_SYMBOL)
}
} else {
/* Default action (only for default buttons) */
- if (RubyDialogCallback_isModal(dref)) {
- if (idx == 0 || idx == 1) {
- rb_ivar_set(itval, SYM2ID(sIsProcessingActionSymbol), Qfalse);
- s_RubyDialog_EndModal(1, &itval, self);
- }
- }
+ if (RubyDialogCallback_isModal(dref) && (idx == 0 || idx == 1)) {
+ rb_ivar_set(itval, SYM2ID(sIsProcessingActionSymbol), Qfalse);
+ s_RubyDialog_EndModal(1, &itval, self);
+ } else retval = Qnil;
}
rb_ivar_set(itval, SYM2ID(sIsProcessingActionSymbol), Qfalse);
- return Qnil;
+ return retval; /* Qtrue: some action was performed, Qnil: none was performed */
}
/* Action for dialog items.
Get the item number, and call "action" method of the RubyDialog object with
the item number (integer) as the argument. The default "action" method is
defined as s_RubyDialog_action. */
-void
+int
RubyDialog_doItemAction(RubyValue self, RDItem *ip, int options)
{
int status;
+ VALUE retval;
void *vp[3];
vp[0] = (void *)(uintptr_t)self;
vp[1] = ip;
vp[2] = (void *)(intptr_t)options;
- rb_protect(s_RubyDialog_doItemAction, (VALUE)vp, &status);
+ retval = rb_protect(s_RubyDialog_doItemAction, (VALUE)vp, &status);
if (status != 0)
Ruby_showError(status);
+ return (retval == Qnil ? 0 : 1);
}
static VALUE
/* Utility function */
extern int RubyDialog_validateItemContent(RubyValue self, RDItem *ip, const char *s);
-extern void RubyDialog_doItemAction(RubyValue self, RDItem *ip, int options);
+extern int RubyDialog_doItemAction(RubyValue self, RDItem *ip, int options);
extern void RubyDialog_doTimerAction(RubyValue self);
extern void RubyDialog_doKeyAction(RubyValue self, int keyCode);
extern int RubyDialog_getFlexFlags(RubyValue self, RDItem *ip);
void
RubyDialogFrame::OnEnterProcessedOnText(wxCommandEvent &event)
{
- RubyDialog_doItemAction((RubyValue)dval, (RDItem *)(event.GetEventObject()), 2);
+ if (RubyDialog_doItemAction((RubyValue)dval, (RDItem *)(event.GetEventObject()), 2) == 0)
+ event.Skip();
}
void
void
RubyDialogFrame::OnEscapeProcessedOnText(wxCommandEvent &event)
{
- RubyDialog_doItemAction((RubyValue)dval, (RDItem *)(event.GetEventObject()), 4);
+ if (RubyDialog_doItemAction((RubyValue)dval, (RDItem *)(event.GetEventObject()), 4) == 0)
+ event.Skip();
}
void