Page 1 of 1 1
Topic Options
#206608 - 2013-01-30 10:59 AM tabkey
Seppe Offline
Fresh Scripter

Registered: 2013-01-09
Posts: 7
Loc: Tenerife
A Kixforms.net richeditBox respects tabs in pasted rtf text.
Can we make the tabkey work?
How to get/set the tab positions?

Thanks ... Seppe

Top
#206609 - 2013-01-30 06:33 PM Re: tabkey [Re: Seppe]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
$NameOfRichTextBox.AcceptsTab = 1
Top
#206612 - 2013-02-01 10:27 AM Re: tabkey [Re: ShaneEP]
Seppe Offline
Fresh Scripter

Registered: 2013-01-09
Posts: 7
Loc: Tenerife
Please try this little script to see the problem.
The arrowkeys work as expected but the tab key is dead.
Thank you, Seppe

 Code:
Break on                                  ; allow break
$t = "{\rtf1\ansi\ansicpg1252\deff0\deflang3082"
$t = $t +"{\fonttbl{\f0\fnil\fcharset0 Times New Roman;}}"
$t = $t + "\viewkind4\uc1\pard\f0\fs20 a\tab b\tab c\par d\tab e\tab f}"
$S = CreateObject("Kixforms.System")       ; S = Kixforms
$R = $S.RichTextBox()                      ; R = RichTextBox
$R.Width = 200                             ;
$R.AcceptsTab = true                       ; R can handle the Tabkey
$R.Rtf = $t                                ; Show text with tabs
$F = $S.Form()                             ; F = Form
$ = $F.Controls.Add($R)                    ; Add R to F
$F.Show                                    ; Displays the Form
While $F.Visible $=Execute($F.DoEvents()) Loop ; wait until closed
Exit 0                                      ; Bye



Edited by Mart (2013-02-01 11:06 AM)
Edit Reason: Please use code tags when posting code.

Top
#206613 - 2013-02-01 09:51 PM Re: tabkey [Re: Seppe]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Try changing

$R.AcceptsTab = true

to...

$R.AcceptsTab = 1

Top
#206614 - 2013-02-01 09:51 PM Re: tabkey [Re: ShaneEP]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
As your example works fine for me when I make above change.
Top
#206615 - 2013-02-01 09:57 PM Re: tabkey [Re: ShaneEP]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4403
Loc: New Jersey
Good eye!

In that case, [true] is a 4-character string assigned to the acceptsTab parameter - will probably not work as desired. This is MUCH different from logical comparisons such as
 Code:
If true
 "true"
else
 "false"
EndIf
?
which will work as expected, but not for the reason you might believe.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#206616 - 2013-02-01 10:24 PM Re: tabkey [Re: Glenn Barnas]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
I'm surprised the script worked at all. It threw an error at me when I tried before changing.
Top
#206620 - 2013-02-02 06:06 PM Re: tabkey [Re: ShaneEP]
Seppe Offline
Fresh Scripter

Registered: 2013-01-09
Posts: 7
Loc: Tenerife
yes, that makes the tabkey work. Thank you.
The second part of my question is:
Is there a simple method to get/set the tab positions.
Thanks
Seppe

Top
#206623 - 2013-02-02 08:50 PM Re: tabkey [Re: Seppe]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Well, just from observation...I created a blank rtf file using wordpad and changed the left and right tabs. Then opened it with notepad and it displays this...

{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}}
{\*\generator Msftedit 5.41.15.1515;}\viewkind4\uc1\pard\li1440\ri8870\f0\fs20\par}

It seems that left and right tab info is the li1440\ri8870 section. Have yet to determine how to convert it though.

Top
#206624 - 2013-02-02 08:56 PM Re: tabkey [Re: ShaneEP]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Also found this page.

http://www.biblioscape.com/rtf15_spec.htm#Heading32

Top
#206625 - 2013-02-02 09:09 PM Re: tabkey [Re: ShaneEP]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
I'm sorry...I believe I got the margin settings confused with the TAB stops. If I adjust the tab stops to one at 1" and one at 4" it adds a couple settings like so..

tx1440\tx5760

Anyone know how to convert those numbers to an understandable version?

Top
#206626 - 2013-02-02 09:17 PM Re: tabkey [Re: ShaneEP]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Ok got it figured out I think. The tab stops are measured in 'twips' (1/1440 an inch), so I wrote a quick function to convert inches to twips and added it to your example. You will notice the letters are now tabbed out at 1 and 4 inches.

 Code:
Break On

$t = "{"+
     "\rtf1\ansi\ansicpg1252\deff0\deflang3082"+
     "{\fonttbl{\f0\fnil\fcharset0 Times New Roman;}}"+
     "\viewkind4\uc1\pard\tx"+InchesToTwips(1)+"\tx"+InchesToTwips(4)+
     "\f0\fs20 A\tab B\tab C\par D\tab E\tab F"+
     "}"

$S = CreateObject("Kixforms.System")

$R = $S.RichTextBox()
$R.Width = 400
$R.AcceptsTab = 1
$R.Rtf = $t

$F = $S.Form()
$F.Width = 420
$nul = $F.Controls.Add($R)

$F.Show()
While $F.Visible
   $nul = Execute($F.DoEvents())
Loop
Exit 0


Function InchesToTwips($inches)
   $InchesToTwips = CDbl($inches)*1440
EndFunction


Edited by ShaneEP (2013-02-02 09:20 PM)

Top
#206627 - 2013-02-02 10:47 PM Re: tabkey [Re: ShaneEP]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4574
Loc: USA
TWIPS? lol. Nice work Shane.
_________________________
(... better days ahead)

Top
#206628 - 2013-02-02 11:13 PM Re: tabkey [Re: Allen]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Yeah, first I had heard of it lol. Apparently it's name comes from 'twentieth of an inch point'.
Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2312 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.07 seconds in which 0.029 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org