0

フィールドのformattedHeightに合わせてユーザーが入力すると成長するLiveCode DataGridにフィールドエディターを作成する必要があります。基礎となる行コントロールの残りの部分も、後続の行コントロールを下にシフトするとともに、サイズを変更する必要があります。

4

2 に答える 2

4

他の人に役立つかもしれないので、自分の質問に答えます。

フィールド エディターの動作ボタンを revDataGridLibrary スタックから、行テンプレートを含むカードにコピーします。

編集するフィールドのスクリプトを次のように編集します (新しいフィールド エディターの動作の長い ID になるように動作ボタンの参照を修正する必要があることに注意してください)。

on preOpenFieldEditor pEditor
   set the behavior of pEditor to the long id of button id 1023 of card id 1010 of stack "Data Grid Templates 1362091650635"
   set the uRowControl of pEditor to the long id of the owner of me
end preOpenFieldEditor

以下を追加して、フィールド エディター動作スクリプトを編集します。

local sHeight,sRowControl

setProp uRowControl pRowControl
   put pRowControl into sRowControl
end uRowControl

on openField
   put the formattedHeight of me into sHeight
   pass openField
end openField

on textChanged
   local tHeight,tRect
   lock screen
   put the formattedHeight of me into tHeight
   if sHeight <> tHeight then
      put the rect of me into tRect
      put item 2 of tRect+ tHeight into item 4 of tRect
      set the rect of me to tRect
      put tHeight into sHeight
      dispatch "UpdateRow" to sRowControl with the long id of me
   end if 
   unlock screen
   pass textChanged
end textChanged

行テンプレートの動作を編集して、次のハンドラーを追加します (この場合、編集中のフィールドの名前は「note」であるため、ユースケースに合わせて変更する必要があることに注意してください)。

on UpdateRow pFieldEditor
   set the rect of graphic "Background" of me to the rect of pFieldEditor
   set the rect of fld "note" of me to the rect of pFieldEditor
   set the rect of me to the formattedRect of me
   put the uScriptLocal["sTableObjectsA"] of me into tTableObjectsA
   repeat for each line tControl in tTableObjectsA["all row controls"]
      delete word -2 to -1 of tControl -- of me
      put tControl into tControlA[the dgIndex of tControl]
   end repeat
   put the bottomLeft of me into tTopLeft
   repeat for each item tIndex in tTableObjectsA["current"]["indexes"]
      if tIndex > the dgIndex of me then
         set the topLeft of tControlA[tIndex] to tTopLeft
         put the bottomLeft of tControlA[tIndex] into tTopLeft
      end if
   end repeat
end UpdateRow
于 2013-03-07T03:40:38.650 に答える
0

モンテ、役に立ちそう。質問: なぜ preOpenField ハンドラーなのですか? その情報を設計時に一度だけ設定することはできませんか? DataGrid は、エディタが呼び出されるたびに新しいフィールド コントロールを作成しますか?

于 2013-03-08T21:39:07.760 に答える