【问题标题】:How to pass a WinForm to Lua (LuaInterface)?如何将 WinForm 传递给 Lua (LuaInterface)?
【发布时间】:2011-10-28 07:36:54
【问题描述】:

我想将一个 WinForm 对象传递给 Lua,我的代码:

//Form1.cs

class Form1
{
  private System.Windows.Forms.TextBox textBox1;
  private System.Windows.Forms.Button button1;

  private void button1_Click(object sender, EventArgs e)
  {
    Lua m_lua = new Lua();
    m_lua.DoFile("plugin.lua");
    object[] objs = m_lua.GetFunction("OnLoad").Call(this, this.textBox1);
    m_lua.Close();
  }
}

--plugin.lua

function OnLoad(form, textbox)
  textbox.Text = form.button1.Text  -->Nil
  textbox.Text = form.button1       -->Expect an object, but got a string!
end

【问题讨论】:

  • OnLoad() 的第一行在 MSVC2005 上为我工作

标签: c# lua luainterface


【解决方案1】:

试试:

m_lua["textBox1"] = this.textBox1;
m_lua.DoString("textBox1.Text = 'hello world'");

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-11-08
    • 2015-03-13
    • 1970-01-01
    • 2023-03-08
    • 2011-05-09
    • 1970-01-01
    • 2019-01-29
    • 1970-01-01
    相关资源
    最近更新 更多