New method controllist.selectitem - Printable Version +- Kodi Community Forum (https://forum.kodi.tv) +-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32) +--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26) +--- Thread: New method controllist.selectitem (/showthread.php?tid=11413) |
- sambarza - 2005-04-15 i 'd like to have a method in object controllist to select an item... i make some changes and prepared a diff... *** controllist.cpp 2005-04-15 19:19:55.516992600 +0200 --- controllist_setitem.cpp 2005-04-15 20:23:31.016983500 +0200 *************** *** 211,240 **** --- 211,267 ---- self->vecitems.push_back(plistitem); // create message cguimessage msg(gui_msg_label_add, self->iparentid, self->icontrolid); msg.setlpvoid(plistitem->item); // send message pyguilock(); if (self->pguicontrol) self->pguicontrol->onmessage(msg); pyguiunlock(); py_incref(py_none); return py_none; } + /* + * controllist_selectitem(int item) + * select an item by index + */ + pydoc_strvar(selectitem, + "selectitem(item) -- select an item by index\n" + "\n" + "item is the index on the item to select."); + + pyobject* controllist_selectitem(controllist *self, pyobject *args) + { + long itemindex; + + if (!pyarg_parsetuple(args, "l", itemindex)) return null; + + // create message + cguimessage msg(gui_msg_item_selected, self->iparentid, self->icontrolid, itemindex); + + // send message + pyguilock(); + if (self->pguicontrol) self->pguicontrol->onmessage(msg); + pyguiunlock(); + + py_incref(py_none); + return py_none; + } + pydoc_strvar(reset, "reset() -- clear all listitems in this control list."); pyobject* controllist_reset(controllist *self, pyobject *args) { // create message controllist *pcontrol = (controllist*)self; cguimessage msg(gui_msg_label_reset, pcontrol->iparentid, pcontrol->icontrolid); // send message pyguilock(); if (pcontrol->pguicontrol) pcontrol->pguicontrol->onmessage(msg); pyguiunlock(); // delete all items from vector *************** *** 376,405 **** --- 403,433 ---- // send message pyguilock(); if ((self->vecitems.size() > 0) && pcontrol->pguicontrol) { pcontrol->pguicontrol->onmessage(msg); plistitem = (pyobject*)self->vecitems[msg.getparam1()]; } pyguiunlock(); py_incref(plistitem); return plistitem; } pymethoddef controllist_methods[] = { {"additem", (pycfunction)controllist_additem, meth_varargs, additem}, + {"selectitem", (pycfunction)controllist_selectitem, meth_varargs, selectitem}, {"reset", (pycfunction)controllist_reset, meth_varargs, reset}, {"getspincontrol", (pycfunction)controllist_getspincontrol, meth_varargs, getspincontrol}, {"getselectedposition", (pycfunction)controllist_getselectedposition, meth_varargs, getselectedposition}, {"getselecteditem", (pycfunction)controllist_getselecteditem, meth_varargs, getselecteditem}, {"setimagedimensions", (pycfunction)controllist_setimagedimensions, meth_varargs, setimagedimensions}, {"setitemheight", (pycfunction)controllist_setitemheight, meth_varargs, setitemheight}, {"setspace", (pycfunction)controllist_setspace, meth_varargs, setspace}, {null, null, 0, null} }; pydoc_strvar(controllist, "controllist class.\n" "\n" "controllist(\n" " x, y, width, height, font, textcolor,\n" - jmarshall - 2005-04-15 adding to cvs. thanks for the patch. - sambarza - 2005-04-15 thanks to you jmarshall! - sambarza - 2005-04-18 selectitem method is not correct... instead of send a message i have created a new method cguilistcontrol:electitem: here are the patchs: selectitem diff i tested and now seems ok i have upload also in http://www.xboxmediacenter.com/upload.htm tracker was down - jmarshall - 2005-04-18 what was wrong with the original technique of sending the select item message? seemed like a suitable method to me. - sambarza - 2005-04-18 nothing happens when i call the method... i don't investigate soo much (i dont't have a development xbox yet) the new patch seems ok but i want to investigate soon as possible (i'm curious)... if you can wait... i will tell you - jmarshall - 2005-04-18 ah - wrong message is what it was. (gui_msg_item_selected rather than gui_msg_item_select) fixed. - sambarza - 2005-04-18 sorry thanks - Phunck - 2005-04-19 thanks alot for this... - tartag - 2006-01-24 -deleted. i'm a moron... :nuts: |