Livecode组合框是否支持多列

Does the Livecode combobox support multiple column

我已将一个实时代码应用程序链接到一个关系数据库。我想使用组合框来显示与 ID 相关的值。我的其他程序(例如 msaccess)是通过具有 2 列的组合框来完成的。第一个链接到 ID 并设置为 0 宽度,第二个显示相关值。这在 livecode 中可能吗?

我有一个文本字段和一个列表字段,我设法在 rawkeyup

上使用以下代码让它工作
global strHilitedLine,strTempHilitedLine,booAfterReturn,booFirstKeyUp

on keyup -- when your press a character key

   TempHilited


end keyup

on returninfield --when user press return key on keyboard

 --accept the temporary hilite
   put the hilitedLine of field "lstfood" into strHilitedLine

   put empty into strTempHilitedLine

   --set booFirstKeyUp to true so that the keyup command will know that
   -- the next keyup is the first after clicking the enter/return key
   put "True" into booFirstKeyUp
   --clear field txtfood
   put empty into fld "txtFood"

end returninfield

on enterkey --when user press enter key on mobile(code same as on returninfield)

   set the hilitedLine of field "lstfood" to strTempHilitedLine
   put the hilitedLine of field "lstfood" into strHilitedLine
   put empty into strTempHilitedLine
   put "True" into booFirstKeyUp
   put empty into fld "txtFood"

end enterkey

on TempHilited

   if booFirstKeyUp="True" then 
   --store the value of hilitedline if this is the first keyup after
   -- clicking enter(see on enterkey)

      put the hilitedLine of field "lstfood" into strHilitedLine
      put "False" into booFirstKeyUp

   end if

   --set hilitedlines to the hilitedlines just after clicking enter
   set the hilitedLine of field "lstfood" to strHilitedLine

   -- cleartemporary hilitedlines from previous keyup
   put empty into strTempHilitedLine

   -- create array from field lstFood and find if the text in txtFood
   -- appears at the start of any item in the array
   put field "lstfood" into arrFood
   filter lines of arrFood with regex pattern "^" & me into strLineText

   --create new value to temporarily hilite
   if the length of strHilitedLine>0 and the length of strLineText>0 then

      put  strHilitedLine &  "," & lineoffset (strLineText ,field
     "lstfood")    after strTempHilitedLine

   else if   the length of strHilitedLine>0 then

      put  strHilitedLine  into strTempHilitedLine

   else if  the length of strLineText>0 then

      put  lineoffset (strLineText ,field "lstfood")  into strTempHilitedLine

   end if

 --set temporay hilite
   set the hilitedLine of field "lstfood" to strTempHilitedLine
   put the length of me into mylength

  --Select the part of txtFood that user did to type so that it is overwritten on the next keyup
   put strlinetext into field "txtFood"
   select char mylength +1 to the length of me of field "txtFood"

End TempHilited

如您所见,这是一个很长很复杂的代码。很高兴听到你有更多 -- 实现相同目标的有效方法。

你提到了 "Store the data in a custom property, filter to include relevant lines, put the remaining data into the field",我相信你是在暗示另一种方法,但我还没有真正弄清楚该怎么做

不,菜单按钮不允许在 LiveCode 中使用多列。但是,可以制作自己的组合框,例如通过为菜单使用堆栈面板并将两个字段添加到该堆栈。使用菜单按钮的属性检查器将堆栈指定为堆栈面板。

很久以前我做了这样一个堆栈面板,只有一列:

将其设为两列菜单很容易:只需将字段宽度减半,添加另一个字段并在焦点字段的 hilitedLine 发生变化时更新没有焦点的字段的 hilitedLine .这个例子不是一个真正的堆栈面板,但它的工作原理几乎相同。我打开作为调色板隐藏的堆栈,设置大小和位置,然后显示它以确保它具有焦点。

(图片来自我自己的网站,图书馆在捐赠者专用区域)