コード例 #1
0
ファイル: ObjectTree.cpp プロジェクト: GustavoMOG/edelib
int ObjectTree::handle(int ev) {
	if(ev == FL_PUSH) {
		const Fl_Tree_Item *clicked = find_clicked();

		if(clicked && clicked->user_data()) {
			/* show prototype as tooltip */
			Entity *e = (Entity*)clicked->user_data();

			if(Fl::event_button() == FL_RIGHT_MOUSE) {
				deselect_all();
				select((Fl_Tree_Item*) clicked);

				/* by default popup() does not call callbacks */
				const MenuItem * m = action_menu->menu()->popup(Fl::event_x(), Fl::event_y());
				if(m && m->callback()) 
					m->do_callback(0, this);
			} else {
				e->get_prototype(tooltip_buf, sizeof(tooltip_buf));

				Fl_Tooltip::current(this);
				Fl::belowmouse(this);
				/*
				 * I will never understaind how 'entity_area()' works, as obviously y coordinate always
				 * gets messed up. Here '50' is hardcoded to fix tooltip messed position.
				 */
				Fl_Tooltip::enter_area(this, clicked->x(), clicked->y() - 50, clicked->w(), clicked->h(), tooltip_buf);
			}
		}
	} else if(ev == FL_LEAVE) {
		Fl_Tooltip::current(NULL);
	}

	return Fl_Tree::handle(ev);
}
コード例 #2
0
void EditorFindDialog::setup_signals(void)
{
 connect(lineEdit, SIGNAL(textChanged(const QString &)),
         this, SLOT(enable_find_button(const QString &)));

 connect(findButton, SIGNAL(clicked()),
         this, SLOT(find_clicked()));
}
コード例 #3
0
int ServerTree::handle(int e){

    if(children() == 0)
        YYY_SetNoServer();

    // Check that the last clicked item is still in the tree.
    bool still_exists = false;
    if(m_last_clicked != NULL){
        for(Fl_Tree_Item *item = first(); item; item = next(item)){
            if(item == m_last_clicked){
                still_exists = true;
                break;
            }
        }
    }

    if(m_last_clicked == NULL || !still_exists){
        m_last_clicked = first();
        if(m_last_clicked == root())
            m_last_clicked = next(m_last_clicked);
        select_only(m_last_clicked);
    }
    if(e == FL_PUSH){
        puts("Push!");
        if(Fl::event_button() == FL_RIGHT_MOUSE){
        
            Fl_Tree_Item *const l_item = find_clicked();
            if(l_item == NULL)
                return Fl_Tree::handle(e);
        
            const unsigned l_x = Fl::event_x(), l_y = Fl::event_y();
            const Fl_Menu_Item *l_menu_item =
                s_right_click_menu->popup(l_x, l_y, NULL, 0, 0);
            if(l_menu_item == NULL)
                return Fl_Tree::handle(e);
            /*
            const unsigned l_index =
                std::distance(static_cast<const Fl_Menu_Item *>(s_right_click_menu),
                    l_menu_item);
            */
            return 1;
        }
    }
    
    // Update the m_last_clicked.
    m_last_clicked = first_selected_item();
    if(m_last_clicked == root())
        m_last_clicked = next(m_last_clicked);

    // Do the default handle
    const int ret = Fl_Tree::handle(e);

    // If we deselected everything, reselect the last item.
    if(first_selected_item() == NULL)
        select_only(m_last_clicked);
    return ret;
}