77 {
78
80
82
84
85 if (event->type == SDL_EVENT_MOUSE_BUTTON_DOWN) {
88 }
89 return true;
90 }
91
92 if (event->type == SDL_EVENT_MOUSE_BUTTON_UP) {
94
95 self->
state &= ~ControlStateHighlighted;
97 if (event->button.clicks) {
98 if (this->delegate.didClick) {
99 this->delegate.didClick(this);
100 }
102 }
103 }
104 return true;
105 }
106
107 if (event->type == SDL_EVENT_MOUSE_MOTION) {
109 return true;
110 }
111 }
112
113 if (event->type == SDL_EVENT_KEY_DOWN) {
114 switch (event->key.key) {
115 case SDLK_SPACE:
116 case SDLK_KP_SPACE:
117 case SDLK_RETURN:
118 case SDLK_KP_ENTER:
119 if (this->delegate.didClick) {
120 this->delegate.didClick(this);
121 }
123 return true;
124 default:
125 break;
126 }
127 }
128
130}
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.