78 {
79
81
83
85
86 if (event->type == SDL_EVENT_MOUSE_BUTTON_DOWN) {
89 }
90 return true;
91 }
92
93 if (event->type == SDL_EVENT_MOUSE_BUTTON_UP) {
95
96 self->
state &= ~ControlStateHighlighted;
98 if (event->button.clicks) {
99 if (this->delegate.didClick) {
100 this->delegate.didClick(this);
101 }
103 }
104 }
105 return true;
106 }
107
108 if (event->type == SDL_EVENT_MOUSE_MOTION) {
110 return true;
111 }
112 }
113
114 if (event->type == SDL_EVENT_KEY_DOWN) {
115 switch (event->key.key) {
116 case SDLK_SPACE:
117 case SDLK_KP_SPACE:
118 case SDLK_RETURN:
119 case SDLK_KP_ENTER:
120 if (this->delegate.didClick) {
121 this->delegate.didClick(this);
122 }
124 return true;
125 default:
126 break;
127 }
128 }
129
131}
static void resignKeyResponder(View *self)
@ ControlStateHighlighted
@ ViewEventClick
A Control received one or more click events.
static bool didReceiveEvent(const View *self, const SDL_Event *event)
static void emitViewEvent(View *self, ViewEvent code, ident data)
Controls are Views which capture and respond to events.
unsigned int state
The bit mask of ControlState.