Just thought I'd share this since it's the only decent place to share GS2 code and I think it's something popup menus should support by default. Basically it lets you scan through popup menus via key input. It supports two methods:
> Jumping through first-key input(scanning through all rows that start with the same letter)
> Jumping to the first row that matches a string of characters
All you had to do is add a catch event to the GuiPopUpMenuCtrl:
PHP Code:
thiso.catchevent(this.name, "onKeyDown", "onScanRows");
Here is the actual code you need to include in the script:
PHP Code:
function onScanRows(temp.obj,temp.code,temp.key) {
if (temp.code == 8) {
if (temp.obj.findObject.length() > 0) {
temp.obj.findObject = temp.obj.findObject.substring(0,temp.obj.findObject.length()-1);
cancelEvents("ForgetObjectFind");
scheduleEvent(.5,"ForgetObjectFind",temp.obj);
}
} else if (temp.key != "") {
temp.scanThrough = (temp.key == temp.obj.lastKey ||
temp.obj.lastKey == "") &&
temp.obj.findObject.length() <= 1;
if (temp.scanThrough) {
temp.obj.findObject = temp.key;
temp.list = new[0];
for (temp.i : temp.obj.rows) {
if (temp.i.text.starts(temp.key)) temp.list.add(temp.i.id);
}
temp.ind = temp.list.index(temp.obj.getselectedid());
for (temp.i=0;temp.i<temp.list.size();temp.i++) {
if (temp.i > temp.ind) break;
}
temp.i = temp.i%temp.list.size();
if (temp.list.size() > 0) temp.obj.setselectedrow(temp.list[temp.i]);
} else {
temp.obj.findObject = temp.obj.findObject @ temp.key;
for (temp.i : temp.obj.rows) {
if (temp.i.text.starts(temp.obj.findObject)) {
temp.obj.setselectedrow(temp.i.id);
break;
}
}
}
temp.obj.lastKey = temp.key;
cancelEvents("ForgetObjectFind");
scheduleEvent(.5,"ForgetObjectFind",temp.obj);
}
}
function onForgetObjectFind(temp.obj) {
temp.obj.lastKey = "";
temp.obj.findObject = "";
}
I had no intention on making something I planned to share, so excuse any mess/sloppy code.