Forum: Ruby-Gnome 2 ScrolledWindow - how to enable scrolling with page up and page down keys?

4828d528e2e46f7c8160c336eb332836?d=identicon&s=25 Robert Heiler (shevegen)
on 2013-12-10 19:30
Hi,

I have a Scrolled Window. The mouse keys work fine, I can scroll up and
down, but not with page up and page down.

Does someone understand why page up and page down does not work or more
importantly how to enable this?

  scrolled_window = Gtk::ScrolledWindow.new
  scrolled_window.add_with_viewport(text_view)

When I am with my cursor inside such a scrolled window, the page up and
page down keys don't seem to make anything.
D9ba13de4e62fcabffa4403731434e42?d=identicon&s=25 Eric C. (eric_c65)
on 2013-12-11 08:30
You could try the key_press event or button_release_event.  Look in the
docs.  Add this line inside the method:

puts "Key number: " + key.to_s

When the program runs, press the pageup key and look at the number.

Then write in your code:

if key == (number)
  <code to make page up..>
end

Hope this helps.

If you're using visualruby, you could just add the method:

scrolledwindow1_key_press(me, key)
  if key.keyval == 65365 #PgUp

  else if key.keyval == 65366 #PgDn

  end
end

Give that a shot.

Eric
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.