KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

Rich Text Box and Buttons and events, oh my.....

 
Post new topic   Reply to topic    KiXforms Forum Index -> Starters Code Clinic
View previous topic :: View next topic  
Author Message
JWood
KiXforms Dabbler
KiXforms Dabbler


Joined: 04 Sep 2008
Posts: 9
Location: Phoenix, AZ

PostPosted: Wed Sep 10, 2008 10:00 pm    Post subject: Rich Text Box and Buttons and events, oh my..... Reply with quote

I have a need to have a button visible but disabled until a user scrolls to the end of a rich text box. Reaching the end of the text box should enable the button on the form. the whole 'read to the end before you can click accept' process.

I don't see any events associated with the Rich Text Box that I could use to find the end of the filed and trigger the Button to be enabled.

I'm open to suggestions here...

Thank you in advance!

-James
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Fri Sep 12, 2008 12:07 pm    Post subject: Reply with quote

Great question! Going to investigate some options today. Anyone else try scripting this yet ?

-Shawn
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Fri Sep 12, 2008 2:01 pm    Post subject: Reply with quote

Here's a scriptlet for those that want to attempt a solution. Looks "challenging" to say the least ...

Code:

Break On

$System = CreateObject("Kixtart.System")

$Form = $System.Form()
$Form.Size = 640, 480

$RichTextBox = $Form.RichTextBox()
$RichTextBox.Location = 10,10
$RichTextBox.Right = $Form.ClientWidth - 10
$RichTextBox.Bottom = $Form.ClientHeight - 50
$RichTextBox.Anchor = 15
$RichTextBox.Text = GetLegalText()

$AcceptButton = $Form.Button()
$AcceptButton.Center
$AcceptButton.Top = $RichTextBox.Bottom + 5
$AcceptButton.Text = "I Accept"
$AcceptButton.Enabled = 0

$Form.Center
$Form.Show
While $Form.Visible
 $= Execute($Form.DoEvents)
Loop

Exit 0

Function GetLegalText()
 Dim $i
 For $i = 1 to 100
  $GetLegalText = $GetLegalText + "This is line " + $i + @CRLF
 Next
EndFunction
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Fri Sep 12, 2008 11:13 pm    Post subject: Reply with quote

k, heres a first stab ...

Code:

Break On

$System = CreateObject("Kixtart.System")

$Form = $System.Form()
$Form.Size = 640, 480
$Form.Text = "Attention! Legal stuff here!"
$Form.FontSize = 10
 
$Label = $Form.Label()
$Label.Location = 10,10
$Label.Width = $Form.ClientWidth - 10
$Label.Text = 'Read the following text. Press PAGEDOWN for more. Click "I Accept" when done.'

$RichTextBox = $Form.RichTextBox()
$RichTextBox.ScrollBars = 0
$RichTextBox.Top = $Label.Bottom + 5
$RichTextBox.Left = 10
$RichTextBox.Right = $Form.ClientWidth - 10
$RichTextBox.Bottom = $Form.ClientHeight - 50
$RichTextBox.Anchor = 15
$RichTextBox.Text = GetLegalText()
$RichTextBox.OnKeyDown = "RichTextBox_KeyDown()"

$TargetSelectionStart = CalculateTargetSelectionStart($RichTextBox)

$AcceptButton = $Form.Button()
$AcceptButton.Center
$AcceptButton.Top = $RichTextBox.Bottom + 5
$AcceptButton.Text = "I Accept"
$AcceptButton.Enabled = 0
$AcceptButton.OnClick = "AcceptButton_Click()"

$Form.Center
$Form.Show
$RichTextBox.Focus

While $Form.Visible
 $= Execute($Form.DoEvents)
Loop

Exit 0

Function GetLegalText()
 Dim $i
 For $i = 1 to 100
  $GetLegalText = $GetLegalText + "This is line " + $i + @CRLF
 Next
EndFunction

Function RichTextBox_KeyDown()

 If $TargetSelectionStart = $RichTextBox.SelectionStart
  $AcceptButton.Enabled = 1
  $AcceptButton.FontBold = 1
 Endif

EndFunction

Function AcceptButton_Click()

 $Form.Hide

EndFunction

Function CalculateTargetSelectionStart($TextBox)

 $Len = Len($TextBox.Text)
 $Rows = UBound(Split($TextBox.Text,CHR(10)))
 $CalculateTargetSelectionStart = $Len - $Rows

EndFunction
Back to top
View user's profile Send private message
JWood
KiXforms Dabbler
KiXforms Dabbler


Joined: 04 Sep 2008
Posts: 9
Location: Phoenix, AZ

PostPosted: Mon Sep 15, 2008 4:03 pm    Post subject: Reply with quote

I see where you are going with this... Let me play with it some and see what happens...

Thanks for the effort!
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Mon Sep 15, 2008 5:12 pm    Post subject: Reply with quote

Yeah, had to turn-off the scrollbar because (as you know) there aint no scroll event Sad
Back to top
View user's profile Send private message
JWood
KiXforms Dabbler
KiXforms Dabbler


Joined: 04 Sep 2008
Posts: 9
Location: Phoenix, AZ

PostPosted: Mon Sep 15, 2008 5:24 pm    Post subject: Reply with quote

Yeah, that was the first event I looked for. I never thought about testing for the cursor location... I think this is going to work for me though! Razz I'll post some samples when I get it working...

Thanks again!
Back to top
View user's profile Send private message
JWood
KiXforms Dabbler
KiXforms Dabbler


Joined: 04 Sep 2008
Posts: 9
Location: Phoenix, AZ

PostPosted: Mon Sep 15, 2008 9:41 pm    Post subject: A Twist... Reply with quote

The issue now seems to be that the rich text box is getting it's content from a file...

Code:
$RichTextBox.LoadFile("FileName.rtf")


Does this affect the .text property? It seems to not be working the same.

UPDATE:

I can return a non-zero number for the elngth of the .Text property after the .LoadFile method executes.

Why would this not work?
Code:
If Len($rtb.Text) = $rtb.SelectionStart
$ButtonAccept.Enabled = 1
EndIf
Back to top
View user's profile Send private message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Tue Sep 16, 2008 3:52 am    Post subject: Reply with quote

$button.enabled is a boolean value.

Therefore to be true set it to -1

_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
JWood
KiXforms Dabbler
KiXforms Dabbler


Joined: 04 Sep 2008
Posts: 9
Location: Phoenix, AZ

PostPosted: Tue Sep 16, 2008 2:55 pm    Post subject: Reply with quote

It seems that .rtf files must have hidden characters in them because the length of the .Text property is 4812 while I can only get the cursor in the rtb to move to character 4784. Where is how I enabled the button...
Code:
Function fnAUAKeyDown()

   $Loc = $rtbAua.SelectionStart
   If $Loc > 4783
   $btnAuaAccept.Enabled = 1
   EndIf

EndFunction

Works just like a champ every time...

Thanks for all the input!!!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> Starters Code Clinic All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group