Author Topic: _str keyname_to_command(_str keyname, int keytab_used)?  (Read 1556 times)

MindprisM

  • Senior Community Member
  • Posts: 126
  • Hero Points: 8
_str keyname_to_command(_str keyname, int keytab_used)?
« on: October 08, 2012, 12:40:06 pm »
I'm on V 12
I've got this to work for some keys but for some reason its not working for all. I only care about _default_keys in the event table.

The following is my getter:
Code: [Select]
_str bind_get_key_cmd(_str keyname,_str k,int keytab_used=_default_keys,int nullret=1)
  {
    // stolen from what_is()
     index=eventtab_index(keytab_used,keytab_used,event2index(k));
     if ( index && (name_type(index)&(COMMAND_TYPE|EVENTTAB_TYPE))) {
       type=name_type(index) & ~(INFO_TYPE|DLLCALL_TYPE);
       type_name=eq_value2name(type& ~INFO_TYPE,HELP_TYPES);
       status=1
       nn=translate(name_name(index),'_','-');
       return nn;
     } else {
        return '';
     }
     return '';
  }

Which works fine with my driver:
Code: [Select]
_command doit(){
   status=prompt_for_key(nls('What is key:')' ',keytab_used,k,keyname,'','','',1);
   Msg('name:"'event2name(k)'"');
   Msg('name:"'_asc(event2name(k))'"');
   Msg('k:'k);
   Msg('keyname:"'keyname'"');
   Msg('keytab_used:'keytab_used);
   clip_set_text(keyname);
   //clip_set_text(k);
   _str cmd=bind_get_key_cmd(keyname,k,keytab_used);
   Msg(cmd);
}

Feeding it data sometimes works:
Code: [Select]
keyname='A-Del Ins';
k=name2event('Ins');
keytab_used=_default_keys;// sometimes I use 17136, which is what the prompt_for_key() returns
_str cmd=bind_get_key_cmd(keyname,k,keytab_used);
Msg(cmd);

This doesn't work:
Code: [Select]
keyname='Ins Ins PgDn Left';
k=name2event('Left');
keytab_used=_default_keys;// sometimes I use 17136, which is what the prompt_for_key() returns
_str cmd=bind_get_key_cmd(keyname,k,keytab_used);
Msg(cmd);

I admit I'm a little bleary eyed at the moment but wtf am I missing?