On Wed, Apr 2, 2014 at 7:53 AM, aullidolu...@gmail.com <aullidolu...@gmail.com> wrote: > The strings "0" to "9" are displayed as expected on the treeview. The idea > is if I hit GDK_KEY_Up (since there's no upper level) should select the > last one; my function moveItemUP, does work in someway, because instead of > selecting the string "9", it selects the string "8".....any ideas...? > > I'm attaching my sandbox project
A few points. Firstly, your attachment(s) didn't arrive; it's generally not a good idea to try to post attachments to mailing lists, as they're often stripped, and if they're not, they get forcibly sent out to a potentially large number of people. If your code's not too long, you could include all of it in-line; otherwise, a link to Github or Bitbucket or somesuch is probably the easiest. Second, your indentation has been eaten by Gmail. This happens, unfortunately - the input box finds tabs delicious. You'll want to replace them with spaces (probably four is enough, but go with eight if there's any chance that you've mixed tabs and spaces - which is a bad idea, though, so don't mix them!) before posting. Third: You'll often find that it's easier to figure out what's going on if you write your code in Python or Pike rather than C. C forces you to do a whole lot of rigmarole that higher-level languages don't require. For comparison, here's a Pike version of your fifty-line snippet: // display 0-9 in the list int addItems(GTK2.ListStore model) { for (int i = 0; i < 10; i++) model->set_value(model->append(), 0, (string)i); return 10; } // grab the number of items dat->totalItems = addItems(listStore); void moveItemUP(mapping dat) { GTK2.TreePath path=dat->tv->get_cursor()->path; GTK2.TreePath prev=path->prev(); if (!prev) { GTK2.TreeIter iter=dat->model->iter_nth_child(0, dat->totalItems-1); dat->tv->set_cursor(dat->model->get_path(iter)); } } // callback int keypress(GTK2.Widget self, object event, mapping data) { switch (event->keyval) { case 0xFF52: moveItemUP(data); break; //GDK_KEY_Up case 0xFF54: moveItemDown(data); break; //GDK_KEY_Down case 0xFF57: break; //GDK_KEY_End default: break; } return 0 } About half the length of code, mainly because I don't have to release resources :) Equivalent Python code would be of comparable length, but would look a lot more different. Finally: Your actual problem seems to be that, after your signal handler (I don't see where you connect to that signal, so I don't know whether you connected before or after), the normal handling still happens. You'll need to return TRUE from your handler if you replace the normal behaviour. (Which means your keypress has to pass through a return value from moveItemUP.) I could see what was going on rather more easily once I shortened the code into the Pike version. :) ChrisA _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list