GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sat Nov 29, 2014 9:44 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: [gtkmm 2.4] pixbuf position, and multi signal event handling
PostPosted: Wed Jan 23, 2013 7:03 am 
Offline

Joined: Wed Jan 23, 2013 6:23 am
Posts: 2
Hello everyone, I am new here, so i dont know if i am posting on the good place. Feel free to point me the good section for my post, Thanks.

I am making a GUI, and I am new to the gtkmm devellopement.

I am looking for a way to catch a mouse click on a Gdk::Pixbuf

Here are my configuration:

my pixbuf is the only item inside my drawingAera.
And my drawingAera is inside a Table, which own several DrawingAera, each of them containing just one picture (Gdk::Pixbuf)

All the class that i use are derivated from the corresponding widget, except for the Gdk::Pixbuf, which i really use.

into the Ctor of my derivated DrawingAera (MyDAera)
i have put the following line:
MyDAera::MyDaera()
{
/*some stuff*/
this->add_events(Gdk::BUTTON_PRESS_MASK);

this->signal_button_press_event().connect(sigc::mem_fun(*this,
&MyDAera::on_button_press_event) );
/*other stuff*/
}
my problem is the following :
When i click on the pixbuf my signal occur which is working as intended, but it also occur when I click on the rest of the Table which own the drawing aera.
If I click on an other Table on my GUI nothing happen as intended.


Could you help to find a way to get the position of my Gtk::_Pixbuf or the position of MyDAera ?


I want to know the position of MyDAera,so i can check if the coordinate of my mouse when i click are realy on the Pixbuf, in order the execute the signal function or not.


i am also trying to catch the signal "ctrl + mouse click"
any idea about how to catch a signal inside a signal.
like catching ctrl press signal then mouse press signal ? ?

thanks for your help.

ps : i am using Gtkmm 2.4


Top
 Profile  
 
 Post subject: Re: [gtkmm 2.4] pixbuf position, and multi signal event hand
PostPosted: Wed Jan 23, 2013 10:23 pm 
Offline
Never Seen the Sunlight

Joined: Thu Mar 24, 2011 2:10 pm
Posts: 328
Location: Sydney, Australia
Yes that would be as I expect. You have your event set up for each drawing area in the table, so it will get fired no matter which one you click on in the table. Unless you have drawing areas only for the cells that will have pixbufs you are not going to be able to stop the function being called, in which case you should look to solve it from within the function. Once the function is called, 1. get the widget which received the signal. 2. Check if this drawing area has an associated pixbuf. 3. return if not. I can't give you too much detail beyond that as I haven't dabbled in c++ much and I imagine details beyond the above would be where c with GObject and gtkmm diverge in implementation.

As for ctrl click, it might be possible but I don't know if it's supported. Principles of accessibility, of which GTK works around, aim at creating UIs that can be operated by users that have difficulties with conventional input and/or display methods, e.g. people with motor control issues. If a UI strictly requires the use of a mouse then it is not accessible to those users. A large amount of mouse functionality can be easily converted to keyboard-only due to focus and accelerators. Something like ctrl-click that is uses both mouse and keyboard simultaneously is also an accessibility issue. A better approach design-wise to get multiple click functionalities would be to have a single click pop-up a combobox where you could then select which option you want. There are probably also plenty of other alternatives depending on your style.


Top
 Profile  
 
 Post subject: Re: [gtkmm 2.4] pixbuf position, and multi signal event hand
PostPosted: Thu Jan 24, 2013 8:36 am 
Offline

Joined: Wed Jan 23, 2013 6:23 am
Posts: 2
thanks a lot i have put one drawing aera for one pixbuf, and now its work as i expected it ^^.

for the ctrl + click, i went into the same direction as you suggest. I have add a MenuList on rightclik, but i dont really know how the sigc::mem_fun work exactly,
so for the moment i cant know on which item i have clicked on my menu.

do you have any idea to find on which item i just clicked on my MenuList, when i am inside the callback function ?

myDAera::MyDaera
{
/*some stuff*/
Gtk::Menu::MenuList& menulist = m_Menu_Popup.items();

menulist.push_back( Gtk::Menu_Helpers::MenuElem("Item 1",
sigc::mem_fun(*this, &MyDaera::on_menu_file_popup_generic) ) );
menulist.push_back( Gtk::Menu_Helpers::MenuElem("Item 2",
sigc::mem_fun(*this, &MyDaera::on_menu_file_popup_generic) ) );
menulist.push_back( Gtk::Menu_Helpers::MenuElem("Item 3",
sigc::mem_fun(*this, &MyDaera::on_menu_file_popup_generic) ) );
/*other stuff*/
}

this code is from the gtkmm 2.4 doc inside a bigger exemple, i just extracted what i wanted, ie : MenuList.

edit : just found the good fonctionon the doc :
get_active();

Thanks for your time.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group