realbasic-nug
[Top] [All Lists]

Re: A way to get half-decent tabs in an RB EditField

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: A way to get half-decent tabs in an RB EditField
From: Tim Jones <tjmac at tolisgroup dot com>
Date: Wed, 28 Mar 2007 11:05:33 -0700
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <20070328164704 dot 3FB85721A76 at mail dot verex dot com>
On Mar 28, 2007, at 9:47 AM, joe at strout dot net wrote:

> So, necessity being a mother and all that, I got inspired to put this
> in the KeyDown event of an EditField:
>
>   static fakeTab As String = Encodings.UTF8.Chr( &h2003 )
>   if Key = Chr(9) then
>     me.selText = fakeTab
>     return true
>   end if
>   return false
>
> Unicode &h2003 is the "Em Space" character.  It's a whitespace
> character that's significantly longer than your typical space
> character.  The code above intercepts any press of the Tab key and
> inserts an Em Space instead.

How about using the regular space character so that you're not tied  
to a specific font?  You could then measure the cursor's current  
position in characters, do modulus math to compare it against a  
tabstop setting and add the appropriate number of spaces (allows user  
to specify tabstops - I use 2 in HTML, 4 in C, and 8 in Python).   
Also, since spaces and character widths will totally mess up the  
layout when using a variable width font, you might consider locking  
the font choices to fixed width fonts.

Tim
--
Tim Jones
tjmac at tolisgroup dot com

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>