objective c - TextView: How to listen or handle space bar key event -


okay 'return' 'insertnewline', love that, in god's green earth insertspace?

so i'm trying invoke spellcheck (for keyword) after user completes word (aka, when hit space bar or return ). daddy needs detect space-bar. heres textview delegate method i'm implementing...

/* listen commands */  -(bool)textview:(nstextview *)atextview docommandbyselector:(sel)aselector {     bool result = no;     if (@selector(insertnewline:) == aselector) {     //      result = yes;      return result;  } return result;  

use delegate method of uitextview follows achieve this...

- (bool)textview:(uitextview *)textview shouldchangetextinrange:(nsrange)range  replacementtext:(nsstring *)text {     // new character added passed in "text" parameter     if ([text isequaltostring:@"\n"]) {         //code when return key pressed.     }     else if([text isequaltostring:@" "])     {         //code when space key pressed.     }     // other character return true text gets added view     return true; } 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -