GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Thu Apr 24, 2014 3:22 am

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: How i can move a gtkscrolledwindow with buttons?
PostPosted: Thu Oct 27, 2011 2:45 pm 
Offline
Familiar Face

Joined: Fri Jul 15, 2011 11:41 am
Posts: 12
I have a gtkscrolledwindow and I want move it with two button (up and down), how I can make this?


Top
 Profile  
 
 Post subject: Re: How i can move a gtkscrolledwindow with buttons?
PostPosted: Fri Oct 28, 2011 8:42 am 
Offline
GTK+ Geek

Joined: Sun Apr 03, 2011 11:12 am
Posts: 63
It already has two scroll bars, why do you want to have two buttons??


Top
 Profile  
 
 Post subject: Re: How i can move a gtkscrolledwindow with buttons?
PostPosted: Sat Oct 29, 2011 3:12 am 
Offline
Never Seen the Sunlight

Joined: Thu Mar 24, 2011 2:10 pm
Posts: 328
Location: Sydney, Australia
I'm also not too sure why buttons are needed. Even in occasions when the window is laid out to require a lot of fine control of the mouse there's always ATK which allows one to scroll it independent of the mouse. But there's always occasions where doing things differently is nice too I guess.
If you'd rather buttons than the scrollbar, then you can note that the scroll is controlled by a gtk_adjustment. In this case you just have to signal connect to the buttons and update the adjustment value accordingly.


Top
 Profile  
 
 Post subject: Re: How i can move a gtkscrolledwindow with buttons?
PostPosted: Mon Oct 31, 2011 5:33 pm 
Offline
Familiar Face

Joined: Fri Jul 15, 2011 11:41 am
Posts: 12
I am working an application without to have that I use the mouse, so I need to known how move the gtkscrolledwindow with two buttons.


Top
 Profile  
 
 Post subject: Re: How i can move a gtkscrolledwindow with buttons?
PostPosted: Mon Oct 31, 2011 7:38 pm 
Offline
Familiar Face

Joined: Fri Jul 01, 2011 6:40 pm
Posts: 48
Location: Croatia
Hi,
You don't have to connect nothing special for controls in container.
Scrolled window is a container and you have to add container for widgets to it and gtkadustment to it.
Then you have to take out set-focus-child event of your container (like table, viewport etc...) and in this handler you have to write code like:
Code:
    gtk_container_set_focus_vadjustment(yourscontainer, youradjustment);


View area will change automatically according focused control with code, mouse or keyboard doesn't matter.
Hope this helps.


Top
 Profile  
 
 Post subject: Re: How i can move a gtkscrolledwindow with buttons?
PostPosted: Mon Oct 31, 2011 8:55 pm 
Offline
Never Seen the Sunlight

Joined: Wed Jul 23, 2008 10:31 am
Posts: 2406
Location: Slovenia
Hi.

To move scrolled window contents using buttons, simply connect to GtkButton::clicked signal and directly modify the GtkAdjustment:value property of adjustment that is used to scroll. There is one adjustment for vertical movement and one for horizontal movement, but you can obtain both of them using gtk_scrolled_window_get_hadjustment() and gtk_scrolled_window_get_vadjustment();

Cheers,
Tadej


Top
 Profile  
 
 Post subject: Re: How i can move a gtkscrolledwindow with buttons?
PostPosted: Wed Nov 02, 2011 11:30 pm 
Offline
Never Seen the Sunlight

Joined: Thu Mar 24, 2011 2:10 pm
Posts: 328
Location: Sydney, Australia
Ok so following on from your last reply where you say "without... mouse" I take it by button you don't mean a displayed widget button but a keyboard button (A widget button is still possible using a keyboard but you would have to tab to it and then press enter much better to just bind a key to the scrollbar -- also as with any widgets that act on other widgets you should ensure to set up relationships with ATK between them).
You need to check out keybindings:
http://developer.gnome.org/gtk/2.24/gtk-Bindings.html
At a guess (never tried this out myself and the documentation's a bit thin) a binding relationship can be set up for example as:
Code:
binding "ScrollMyWindow" {
  bind "<Alt>Up" {
    "my-scroll-down" ()
  }
  bind "<Alt>Down" {
    "my-scroll-down" ()
  }
}
class "GtkWidget" binding "ScrollMyWindow"

Then install the binding, set-up customised signals "my-scroll-up" and "my-scroll-down" and code the signal handlers which will just update the adjustment for the scrollbar.


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 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:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group