View Single Post
  #1  
Old 08-26-2015, 08:24 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
GuiPopUpMenuCtrl user input scanning

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:
Graal Script Code:
thiso.catchevent(this.name"onKeyDown""onScanRows"); 
Here is the actual code you need to include in the script:

Graal Script 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.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.temp.ind) break;
      }
      
temp.temp.i%temp.list.size();
      if (
temp.list.size() > 0temp.obj.setselectedrow(temp.list[temp.i]);
    } else {
      
temp.obj.findObject temp.obj.findObject temp.key;
      for (
temp.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.
Reply With Quote