[MonoDevelop] Stetic add-in and treeview widget event question

Paddy Joy mono at paddyjoy.com
Sat Apr 8 21:50:28 EDT 2006


Hi,

I have recently started playing with the new monodevelop stetic add-in, 
I'm very impressed, well done everyone!

Just as a simple test what I am trying to do is add a treeview to my 
main window and then when a user clicks on a treeview item I want to 
take an action. So far my event handlers work ok for the KeyReleaseEvent 
but don't work for the ButtonPressEvent. These are the exact steps I'm 
doing in monodevelop:

1.      Create new gtk# project
2.      Double click to open MainWindow in gui editor
3.      Add treeview to main window
4.      Click on signals tab
5.      Under Common Widget Signals double click on KeyReleaseEvent to 
add event handler
6.      Under Common Widget Signals double click on ButtonPressEvent to 
add event handler
7.      Click on source tab to see code for MainWindow.cs
8.      Add Console.WriteLine()'s to both handlers
9.      Add some code to populate the treeview

        TreeView                treeview1;
:
:
:
:

        Gtk.ListStore musicListStore = new Gtk.ListStore (typeof 
(Gdk.Pixbuf),
                        typeof (string),  typeof (string));

                treeview1.AppendColumn ("Icon", new 
Gtk.CellRendererPixbuf (), "pixbuf", 0);
                treeview1.AppendColumn ("Artist", new 
Gtk.CellRendererText (), "text", 1);
                treeview1.AppendColumn ("Title", new 
Gtk.CellRendererText (), "text", 2);

                musicListStore.AppendValues (new Gdk.Pixbuf 
("TreeViewRupertIcon.png"),
                        "Rupert", "Yellow bananas");

                treeview1.Model = musicListStore;

10.     Compile and run project
11.     Click on treeview item then press a key, text writen to console 
as expected
12.     Click on item, no text writen to console

It seems like my ButtonPressEvent handler is never being called. Am I 
doing something wrong here? I have attached some relevant code.

Thanks,
Paddy

-------------- next part --------------
A non-text attachment was scrubbed...
Name: MainWindow.cs
Type: text/x-csharp
Size: 4545 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/monodevelop-list/attachments/20060409/4cd625f9/MainWindow.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: generated.cs
Type: text/x-csharp
Size: 6663 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/monodevelop-list/attachments/20060409/4cd625f9/generated.bin
-------------- next part --------------
<?xml version="1.0" encoding="utf-8"?>
<stetic-interface>
  <widget class="Gtk.Window" id="MainWindow" design-size="400 300">
    <property name="Title" translatable="yes">My eBay Selling</property>
    <property name="WindowPosition">CenterOnParent</property>
    <property name="Visible">True</property>
    <property name="Events">0</property>
    <signal name="DeleteEvent" handler="OnDeleteEvent" />
    <child>
      <widget class="Gtk.VBox" id="vbox1">
        <property name="Visible">True</property>
        <property name="Events">0</property>
        <child>
          <widget class="Gtk.HBox" id="hbox1">
            <property name="Visible">True</property>
            <property name="Events">0</property>
            <child>
              <widget class="Gtk.Button" id="button1">
                <property name="Type">TextOnly</property>
                <property name="Label" translatable="yes">button1</property>
                <property name="IsDialogButton">False</property>
                <property name="Visible">True</property>
                <property name="CanFocus">True</property>
                <property name="Events">0</property>
                <signal name="Clicked" handler="OnButton1Clicked" />
              </widget>
              <packing>
                <property name="AutoSize">True</property>
                <property name="Expand">False</property>
                <property name="Fill">False</property>
              </packing>
            </child>
            <child>
              <widget class="Gtk.Button" id="button2">
                <property name="Type">TextOnly</property>
                <property name="Label" translatable="yes">button2</property>
                <property name="IsDialogButton">False</property>
                <property name="Visible">True</property>
                <property name="CanFocus">True</property>
                <property name="Events">0</property>
                <signal name="Clicked" handler="OnButton2Clicked" />
              </widget>
              <packing>
                <property name="Position">1</property>
                <property name="AutoSize">True</property>
                <property name="Expand">False</property>
                <property name="Fill">False</property>
              </packing>
            </child>
            <child>
              <widget class="Gtk.Button" id="button3">
                <property name="Type">TextOnly</property>
                <property name="Label" translatable="yes">button3</property>
                <property name="IsDialogButton">False</property>
                <property name="Visible">True</property>
                <property name="CanFocus">True</property>
                <property name="Events">0</property>
                <signal name="Clicked" handler="OnButton3Clicked" />
              </widget>
              <packing>
                <property name="Position">2</property>
                <property name="AutoSize">True</property>
                <property name="Expand">False</property>
                <property name="Fill">False</property>
              </packing>
            </child>
          </widget>
          <packing>
            <property name="AutoSize">True</property>
            <property name="Expand">False</property>
            <property name="Fill">False</property>
          </packing>
        </child>
        <child>
          <widget class="Gtk.Label" id="label1">
            <property name="LabelProp" translatable="yes">label1</property>
            <property name="Visible">True</property>
            <property name="Events">0</property>
          </widget>
          <packing>
            <property name="Position">1</property>
            <property name="AutoSize">True</property>
            <property name="Expand">False</property>
            <property name="Fill">False</property>
          </packing>
        </child>
        <child>
          <widget class="Gtk.ScrolledWindow" id="scrolledwindow2">
            <property name="VscrollbarPolicy">Automatic</property>
            <property name="HscrollbarPolicy">Automatic</property>
            <property name="Visible">True</property>
            <property name="CanFocus">True</property>
            <property name="Events">0</property>
            <child>
              <widget class="Gtk.TreeView" id="treeview">
                <property name="Visible">True</property>
                <property name="CanFocus">True</property>
                <property name="Events">ButtonPressMask</property>
                <signal name="RowActivated" handler="OnTreeviewRowActivated" />
                <signal name="ButtonPressEvent" handler="OnTreeviewButtonPressEvent" after="yes" />
                <signal name="KeyPressEvent" handler="OnTreeviewKeyPressEvent" after="yes" />
              </widget>
            </child>
          </widget>
          <packing>
            <property name="Position">2</property>
            <property name="AutoSize">True</property>
          </packing>
        </child>
      </widget>
    </child>
  </widget>
</stetic-interface>


More information about the Monodevelop-list mailing list