本文整理汇总了C++中EventHandler::mouse_press方法的典型用法代码示例。如果您正苦于以下问题:C++ EventHandler::mouse_press方法的具体用法?C++ EventHandler::mouse_press怎么用?C++ EventHandler::mouse_press使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventHandler
的用法示例。
在下文中一共展示了EventHandler::mouse_press方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
static gboolean
on_button_press (GtkWidget *widget, GdkEventButton *event, void *user_data)
{
Viewer *self = (Viewer*) user_data;
gtku_gl_drawing_area_set_context (self->gl_area);
double ray_start[3];
double ray_dir[3];
_window_coord_to_ray (event->x, widget->allocation.height - event->y, ray_start, ray_dir);
// find a new picker?
double best_distance = HUGE;
EventHandler *best_handler = NULL;
if (self->picking_handler == NULL || self->picking_handler->picking==0) {
for (unsigned int eidx = 0; eidx < g_ptr_array_size(self->event_handlers); eidx++) {
EventHandler *handler = g_ptr_array_index(self->event_handlers, eidx);
if (handler->enabled && handler->pick_query) {
double this_distance = handler->pick_query(self, handler, ray_start, ray_dir);
if (this_distance < best_distance && this_distance >= 0) {
best_distance = this_distance;
best_handler = handler;
}
}
}
// notify the new handler
if (best_handler)
viewer_request_pick(self, best_handler);
}
// give picking handler first dibs
int consumed = 0;
if (self->picking_handler && !self->picking_handler->picking)
self->picking_handler = NULL;
if (self->picking_handler && self->picking_handler->enabled && self->picking_handler->mouse_press) {
consumed = self->picking_handler->mouse_press(self, self->picking_handler, ray_start, ray_dir, event);
update_status_bar(self);
}
// try all the other handlers in order of priority
for (unsigned int eidx = 0; !consumed && eidx < g_ptr_array_size(self->event_handlers); eidx++) {
EventHandler *handler = g_ptr_array_index(self->event_handlers, eidx);
if (handler != self->picking_handler && handler->enabled && handler->mouse_press)
if (handler->mouse_press(self, handler, ray_start, ray_dir, event))
break;
}
return TRUE;
}