New topic: 

Misfiring Delegated Timer

<http://forums.realsoftware.com/viewtopic.php?t=24884>

       Page 1 of 1
   [ 1 post ]                 Previous topic | Next topic         Author  
Message       Jason_Adams           Post subject: Misfiring Delegated 
TimerPosted: Mon Oct 20, 2008 4:34 pm                        
Joined: Fri Nov 10, 2006 4:10 pm
Posts: 219              I'm presently attempting to create a subclass of 
EditField that has a timer which triggers once the user starts typing, resets 
as they continue to type, and when it finally hits its time or loses focus, it 
fires an event. This way I don't have to wait for the EditField to lose focus, 
or fire every time a key is pressed - thus easing a bit on the processing of 
said EditField... Bad explanation, but anyway, it's using a delegated timer so 
that the Action event of said Timer calls a method within the EditField which 
fires the event.... Seemed a bit shaky, but I thought I'd give it a shot. 
Here's my code:
Code:Class EditFieldTimed
  
  Event TimerFired()
  
  Sub LostFocus()
  InputTimer.Enabled = False
  InputTimer.Reset()
  TimerFired
  End Sub
  
  Sub Open()
  InputTimer = New DelegatedTimer(AddressOf callTimerFired)
  InputTimer.Enabled = False
  InputTimer.Mode = 1
  InputTimer.Period = 1500
  End Sub
  
  Sub TextChanged()
  If InputTimer.Enabled Then
  InputTimer.Reset()
  Else
  InputTimer.Enabled = True
  End If
  End Sub
  
  Sub CallTimerFired()
  InputTimer.Enabled = False
  TimerFired
  End Sub
  
End Class


Class DelegatedTimer
  
  Private Delegate Sub ActionDelegate()
  
  Sub Action()
  MethodToUse.Invoke
  End Sub
  
  Sub Constructor(d As ActionDelegate)
  MethodToUse = d
  End Sub
  
  Private MethodToUse As ActionDelegate
  
End Class



Now, for testing I have it so that when the TimerFired event goes off, it pops 
up a MsgBox telling me which EditField fired. If I type something in and switch 
fields, it works just fine; if I type something in and wait, it pops up an 
empty MsgBox - not just empty in that it has no text, but empty in that it 
doesn't even have the usual "OK" button to close the window.

I'm really not sure on this one, how would it fire the MsgBox but not its 
parameters? Did I find a bug?

Thanks!   
                            Top            Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 1 post ]     

-- 
Over 900 classes with 18000 functions in one REALbasic plug-in. 
The Monkeybread Software Realbasic Plugin v8.1. 

&lt;http://www.monkeybreadsoftware.de/realbasic/plugins.shtml&gt;

[email protected]

Reply via email to