Re: Change cursor
- From: pks timing com
- To: Andreas Volz <lists brachttal net>
- Cc: gtkmm-list <gtkmm-list gnome org>
- Subject: Re: Change cursor
- Date: Fri, 28 Oct 2005 11:33:09 -0600
Andreas Volz writes:
>
> Hm, I run this code in a member function of a class that inherit from
> Gtk::Window. So I think it's realized. But I tried to run realize()
> just before I call this function, without better results.
You can verify that the window is realized using Gtk::Widget::is_realized()
on the the window. You can also see if the gdk window pointer is null using
Glib::RefPtr<>::is_null(). See if your code crashes after the window
has positively been realized:
class TestWindow : public Gtk::Window
{
protected:
virtual void on_realize()
{
// do standard realization dance
Gtk::Window::on_realize();
// then change the cursor
Glib::RefPtr<Gdk::Window> window = this->get_window();
// you won't see this message after Gtk::Window::on_realize() above
if (window.is_null())
std::cerr << "realized gtk window without gdk window!\n";
Gdk::Cursor cursor(Gdk::CLOCK);
window->set_cursor(cursor);
}
};
If you know you want to change the cursor before the window is realized,
write a function which sets the cursor if your window is_realized(),
otherwise tracks which cursor you requested and the installs it in the
on_realize() override, passing the recorded enum instead of the Gdk::CLOCK
constant.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]