We have detected that cookies are not enabled on your browser. Please enable cookies to ensure the proper experience.
Results 1 to 3 of 3
  1. #1

    All I want to do is...

    ... have a button that's disabled unless there is text in a specific textbox. I'd like to catch an event on the textbox when the user types in it and toggle the button from there, but KeyUp/KeyDown only fire for a limited list of API-defined key commands. Is there any way to do this? I tried playing with the Update event, but I got errors every time I defined a function for it and I'm not sure it's the right place to do this anyway.
    [charsig=http://lotrosigs.level3.turbine.com/04208010000096fc1/signature.png]Kerschplat[/charsig]

  2. #2
    Join Date
    Mar 2007
    Posts
    1,191

    Re: All I want to do is...

    Try something like:
    Code:
     self.Texttest=Turbine.UI.Lotro.TextBox();
     self.Texttest:SetParent(self);
     self.Texttest.Text="";
     self.Texttest:SetWantsUpdates(false);
    :
    :
     self.Texttest.Update=function()
      if self.Texttest.Text~=self.SearchText:GetText() then
       self.Texttest.Text=self.SearchText:GetText();
       -- perform some action here, like setting a button enabled
      end
     end
    :
    :
     self.VisibleChanged = function()
      self.SearchText:SetWantsUpdates(self:IsVisible());
     end
    For an example of this actually working, check out the SearchText control in main.lua from AltInventory - it performs an inventory update and search every time the text in the Search field changes.
    Note: to avoid performance issues, it is fairly important to call SetWantsUpdates(false) when the control is not visible so that you aren't wasting processing time handling updates that aren't important, then call SetWantsUpdates(true) when the control should be visible and getting updates.

    If you're getting an error, you might be accidentally using the wrong syntax to define the event handler like using a colon by accident - ex. "self.Texttest:Update=function ()" is a common error.
    Last edited by Garan; Feb 08 2011 at 06:00 PM.

  3. #3

    Re: All I want to do is...

    Thanks, that worked! I've been looking at AltInventory quite a bit anyway because the plugin I'm playing with needs to look at multiple characters across an account in a similar way; I'm surprised I missed that.
    [charsig=http://lotrosigs.level3.turbine.com/04208010000096fc1/signature.png]Kerschplat[/charsig]

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

This form's session has expired. You need to reload the page.

Reload