Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Mac > OOP Powerplant for Mac > Re: setting max...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 2 Topic 468 of 484
Post > Topic >>

Re: setting maximum length of TERec structure ( mac)

by David Phillip Oster <oster@[EMAIL PROTECTED] > Apr 27, 2007 at 02:41 PM

In article 
<ad89a2b9c20fdb1ead08c995194e075e@[EMAIL PROTECTED]
>,
 "vcmac" <sanjaya.busi@[EMAIL PROTECTED]
> wrote:

> Hi,
> 
> How could we set the maximum lenght of a TERec structure.
> We want to set the maximum lenght for extended-edit type in mac to
suppose
> 32767,
> How should we do it ?
> 
> we coded like as below. But still (*teHandle)->teLength is not modified.
> where teHandle is of typr **TERec
> 
> if( len > 32767 )	
> {
> 	len = 32767;
> 	HLock ((Handle)teHandle) ; 
> 	(*teHandle)->teLength = len;
> 	(*teHandle)->selEnd = (*teHandle)->teLength ;
> 	HUnlock ((Handle)teHandle) ;
> }
> 
> Please suggest any way to achieve this ?
> 
> Thanks and Regards
> Sanjaya

In my own code, I use a keyDown handler that, after it has checked for
Clear, Left, Right, Up, Down, Home, End, PageUp, PageDown, and backSpace 
does:

   if(TEMAX -1 <= (**text).teLength){
      TellAnyError(MUSTTRUNCATE);
   }else{
      TEKey(chr, text);
   }

With a similar protection on Paste.

There is similar code in LTextEditView.cp

1.) a TE can't handle even 32767 characters. Pick a smaller maximum.
2.) You don't need to lock a teHandle to assign to if from simple 
variables.
3.) Rarely do HLock() xxx HUnlock(). What if it were already locked on 
entry?
You should use HGetState(); HLock(); xxx HSetState();
4.) Don't assign to selEnd. Use TESetSelection()
5.) You also have to resize the actual hText text handle with 
SetHandleSize()
 




 2 Posts in Topic:
setting maximum length of TERec structure ( mac)
"vcmac" <san  2007-04-27 05:54:08 
Re: setting maximum length of TERec structure ( mac)
David Phillip Oster <o  2007-04-27 14:41:27 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Nov 21 23:35:54 CST 2008.