Reputation: 327
I am designing a GUI that requires kinetic scrolling for my application and I am using GTK (coming from Qt) and I have the following code:
Gtk::Window * wnd = new Gtk::Window();
Gtk::ScrolledWindow * scr = new Gtk::ScrolledWindow();
Gtk::Layout * lay = new Gtk::Layout();
Gtk::VBox * vbox = new Gtk::VBox();
wnd->add(*scr);
scr->add(*vbox);
for (int i = 0; i < 20; i++)
{
Gtk::Button * btn = new Gtk::Button();
btn->set_label("Click Me");
vbox->pack_start(*btn);
btn->show();
}
scr->set_kinetic_scrolling(true);
wnd->show();
scr->show();
lay->show();
vbox->show();
and this is what you get:
This link tells me the following:
void Gtk::ScrolledWindow::set_kinetic_scrolling ( bool kinetic_scrolling = true )
Turns kinetic scrolling on or off.
Kinetic scrolling only applies to devices with source Gdk::SOURCE_TOUCHSCREEN.
Since gtkmm 3.4:
Parameters kinetic_scrolling true to enable kinetic scrolling.
I tried grabbing the button with the mouse and to kinetically scroll but as expected, it does not work. I don't have a touch screen yet and I need to experiment with my mouse, Is there any way I can do this?
I also found the following:
enum InputSource {
SOURCE_MOUSE,
SOURCE_PEN,
SOURCE_ERASER,
SOURCE_CURSOR,
SOURCE_KEYBOARD,
SOURCE_TOUCHSCREEN,
SOURCE_TOUCHPAD,
SOURCE_TRACKPOINT,
SOURCE_TABLET_PAD
}
An enumeration describing the type of an input device in general terms.
Is there any way I can emulate the type of device? I want to see it working.
Upvotes: 4
Views: 510
Reputation: 4104
You must have a touch event. Use GtkInspector (Ctrl+Shift+I) then in the Visual tab, set Simulate touchscreen (as shown below):
It should work. More on Gtk Inspector
Upvotes: 4