Example #1
0
        static bool HandleInput()
        {
            bool HasInput = FrameBuffered == null || Dev.Events.Count > 0;

            if (HasInput)
            {
                Nuklear.nk_input_begin(Ctx);

                while (Dev.Events.Count > 0)
                {
                    NuklearEvent E = Dev.Events.Dequeue();

                    switch (E.EvtType)
                    {
                    case NuklearEvent.EventType.MouseButton:
                        Nuklear.nk_input_button(Ctx, (nk_buttons)E.MButton, E.X, E.Y, E.Down ? 1 : 0);
                        break;

                    case NuklearEvent.EventType.MouseMove:
                        Nuklear.nk_input_motion(Ctx, E.X, E.Y);
                        break;

                    case NuklearEvent.EventType.Scroll:
                        Nuklear.nk_input_scroll(Ctx, new nk_vec2()
                        {
                            x = E.ScrollX, y = E.ScrollY
                        });
                        break;

                    case NuklearEvent.EventType.Text:
                        for (int i = 0; i < E.Text.Length; i++)
                        {
                            if (!char.IsControl(E.Text[i]))
                            {
                                Nuklear.nk_input_unicode(Ctx, E.Text[i]);
                            }
                        }

                        break;

                    case NuklearEvent.EventType.KeyboardKey:
                        Nuklear.nk_input_key(Ctx, E.Key, E.Down ? 1 : 0);
                        break;

                    case NuklearEvent.EventType.ForceUpdate:
                        break;

                    default:
                        throw new NotImplementedException();
                    }
                }

                Nuklear.nk_input_end(Ctx);
            }

            return(HasInput);
        }
Example #2
0
        public static void HandleInput()
        {
            Nuklear.nk_input_begin(Ctx);

            while (Dev.Events.Count > 0)
            {
                NuklearEvent E = Dev.Events.Dequeue();

                switch (E.EvtType)
                {
                case NuklearEvent.EventType.MouseButton:
                    Nuklear.nk_input_button(Ctx, (nk_buttons)E.MButton, E.X, E.Y, E.Down ? 1 : 0);
                    break;

                case NuklearEvent.EventType.MouseMove:
                    Nuklear.nk_input_motion(Ctx, E.X, E.Y);
                    break;

                case NuklearEvent.EventType.Scroll:
                    Nuklear.nk_input_scroll(Ctx, new nk_vec2()
                    {
                        x = E.ScrollX, y = E.ScrollY
                    });
                    break;

                case NuklearEvent.EventType.Text:
                    for (int i = 0; i < E.Text.Length; i++)
                    {
                        Nuklear.nk_input_unicode(Ctx, E.Text[i]);
                    }
                    break;

                case NuklearEvent.EventType.KeyboardKey:
                    Nuklear.nk_input_key(Ctx, E.Key, E.Down ? 1 : 0);
                    break;

                default:
                    throw new NotImplementedException();
                }
            }

            Nuklear.nk_input_end(Ctx);
        }