ext/nuklear/nkrb_context.c in nuklear-0.1.1 vs ext/nuklear/nkrb_context.c in nuklear-0.1.2
- old
+ new
@@ -218,12 +218,25 @@
rb_need_block();
rb_funcall_with_block(ui, rb_intern("instance_eval"), 0, NULL, rb_block_proc());
return ui;
}
+static VALUE nkrb_context_is_any_editor_active(VALUE self) {
+ struct nk_context *ctx = nkrb_context_get(self);
+ struct nk_window *iter;
+ iter = ctx->begin;
+ while (iter) {
+ if (iter->edit.active & NK_EDIT_ACTIVE)
+ return Qtrue;
+ iter = iter->next;
+ }
+ return Qfalse;
+}
+
static VALUE nkrb_context_is_any_item_active(VALUE self) {
struct nk_context *ctx = nkrb_context_get(self);
+ if (nkrb_context_is_any_editor_active(self) == Qtrue) return Qtrue;
return nk_item_is_any_active(ctx) ? Qtrue : Qfalse;
}
void nkrb_context_init(void) {
cNuklearContext = rb_define_class_under(mNuklear, "Context", rb_cObject);
@@ -232,9 +245,10 @@
rb_define_method(cNuklearContext, "user_data", nkrb_context_get_user_data, 0);
rb_define_method(cNuklearContext, "initialize", nkrb_context_initialize, 1);
rb_define_method(cNuklearContext, "tick", nkrb_context_tick, 0);
rb_define_method(cNuklearContext, "ui", nkrb_context_ui, 0);
rb_define_method(cNuklearContext, "any_item_active?", nkrb_context_is_any_item_active, 0);
+ rb_define_method(cNuklearContext, "any_editor_active?", nkrb_context_is_any_editor_active, 0);
cNuklearContextEventSink = rb_define_class_under(cNuklearContext, "EventSink", rb_cObject);
rb_define_method(cNuklearContextEventSink, "initialize", rb_nkrb_event_sink_initialize, 1);
rb_define_method(cNuklearContextEventSink, "motion", nkrb_event_sink_motion, 4);
rb_define_method(cNuklearContextEventSink, "key", nkrb_event_sink_key, 2);