Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #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:
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.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
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 04:54 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.