在两个单独的列表之间移动可编辑项目?

时间:2015-02-13 19:26:23

标签: list livecode

我需要至少10个声望来发布图片(只有8个)

列表的图片是第一次打开应用程序时看到的内容 1.单击列表,让我点击的内容填写编辑卡上的标题。 2.查看编辑卡上的其他两个字段(日期和时间)。将它们连接到原始列表上的标题,并能够使用仅显示特定于所单击标题的数据填充它们。 3.(如果可能)可以选择拍照并将其显示在黑匣子中的编辑卡上。 4.有两个相同的列表(在不同的卡上),我想要做与上面相同的功能。 5.能够在两个列表之间移动项目。

Card Edit: 
on preopencard   
   ## Populate the fields
   put empty into field "title 2"
   put empty into field "description 2"
   put the long date into field "date 2"

   ## Check which task we want to edit 
   ## using the custom property set on this card when we selected a task from the list
   put the cTaskID2 of me into tTaskID2

   ## Get the current details of the task
   put taskDetail2(tTaskID2, "title 2") into tTitle2
   put taskDetail2(tTaskID2, "description 2") into tDescription2
   put taskDetail2(tTaskID2, "completed 2") into tCompleted2
   ## And display then in the relevant fields
   put tTitle2 into field "title 2"
   put tDescription2 into field "description 2"

   ## Set the label of the completed button to allow you to toggle the state
   if tCompleted2 then
      set the label of button "completed 2" to "mark as incomplete"
   else
      set the label of button "completed 2" to "mark as complete"
   end if
end preopencard

on closeCard
   ## Check which task we want to update 
   ## using the custom property set on this card when we selected a task from the list
   put the cTaskID2 of me into tTaskID2

   if tTaskID2 is not empty then
      ## Update the task data in the cTaskData custom property of the stack
      updateTask2 tTaskID2, field "title 2", field "description 2"

      ## Save the task data out to file, ensures our file always refelects the current state
     saveTaskData
   end if
end closeCard



Stack script: (The ones with 2 are for this card) 


on preOpenStack
   ## Read the task list in from file
   readTaskData
end preOpenStack

on addTask pTitle, pDescription
   ## Add a task to the custom property of the stack that is storing the task list
   ## Remember you cannot update a part of a custom property
   ## It must be set in its entirety

  put the cTaskData of me into tTaskDetails
  put pTitle & tab & pDescription & tab & "false" & return after tTaskDetails
  set the cTaskData of me to tTaskDetails
end addTask

on addTask2 pTitle2, pDescription2
   ## Add a task to the custom property of the stack that is storing the task list
   ## Remember you cannot update a part of a custom property
   ## It must be set in its entirety

  put the cTaskData2 of me into tTaskDetails2
  put pTitle2 & tab & pDescription2 & tab & "false" & return after tTaskDetails2
  set the cTaskData2 of me to tTaskDetails2
end addTask2

on updateTask pLineNumber, pTitle, pDescription, pCompleted, 
   ## Update the details for  the given task in the custom property of the stack thast is storing the task list

   put the cTaskData of me into tTaskDetails
   set the itemDel to tab

   if pTitle <> empty then put pTitle into item 1 of line pLineNumber of tTaskDetails
   if pDescription <> empty then put pDescription into item 2 of line pLineNumber of tTaskDetails
   if pCompleted <> empty then put pCompleted into item 3 of line pLineNumber of tTaskDetails
   set the cTaskData of me to tTaskDetails
end updateTask

on updateTask2 pLineNumber2, pTitle2, pDescription2, pCompleted2, 
   ## Update the details for  the given task in the custom property of the stack thast is storing the task list

   put the cTaskData2 of me into tTaskDetails2
   set the itemDel to tab

   if pTitle2 <> empty then put pTitle into item 1 of line pLineNumber2 of tTaskDetails2
   if pDescription2 <> empty then put pDescription2 into item 2 of line pLineNumber2 of tTaskDetails2
   if pCompleted2 <> empty then put pCompleted2 into item 3 of line pLineNumber2 of tTaskDetails2
   set the cTaskData2 of me to tTaskDetails2
end updateTask2

on deleteTask pLineNumber
   ## Delete the given task from the custom property of the stack
   ## Remember the task id corresponds to the line number of the task in the custom property
   put the cTaskData of me into tTaskDetails
   delete line pLineNumber of tTaskDetails
   set the cTaskData of me to tTaskDetails
end deleteTask

on deleteTask2 pLineNumber2
   ## Delete the given task from the custom property of the stack
   ## Remember the task id corresponds to the line number of the task in the custom property
   put the cTaskData2 of me into tTaskDetails2
   delete line pLineNumber2 of tTaskDetails2
   set the cTaskData2 of me to tTaskDetails2
end deleteTask2

on deleteAllTasks
   ## Delete all tasks
   set the cTaskData of me to empty
end deleteAllTasks

on deleteAllTasks2
   ## Delete all tasks
   set the cTaskData2 of me to empty
end deleteAllTasks2

function taskDetail pLineNumber, pDetailType
   ## Get the specified detail of the specified task
   ## Remember each line of the custom property represents a task
   ## and the task details are tab separated

  put the cTaskData of me into tTaskDetails
  set the itemDel to tab
  switch pDetailType
    case "title"
      put item 1 of line pLineNumber of tTaskDetails into tDetail
      break
    case "description"
      put item 2 of line pLineNumber of tTaskDetails into tDetail
      break
    case "completed"
      put item 3 of line pLineNumber of tTaskDetails into tDetail
      break
  end switch
  return tDetail
end taskDetail

function taskDetail2 pLineNumber2, pDetailType2
   ## Get the specified detail of the specified task
   ## Remember each line of the custom property represents a task
   ## and the task details are tab separated

  put the cTaskData2 of me into tTaskDetails2
  set the itemDel to tab
  switch pDetailType2
    case "title2"
      put item 1 of line pLineNumber2 of tTaskDetails2 into tDetail2
      break
    case "description2"
      put item 2 of line pLineNumber2 of tTaskDetails2 into tDetail2
      break
    case "completed2"
      put item 3 of line pLineNumber2 of tTaskDetails2 into tDetail2
      break
  end switch
  return tDetail2
end taskDetail2

function taskCount
   ## Find out how many tasks are currently in the list
   return the number of lines in the cTaskData of me
end taskCount

function taskCount2
   ## Find out how many tasks are currently in the list
   return the number of lines in the cTaskData2 of me
end taskCount2

on saveTaskData
   ## Build the path to the file we want to store the data in
   ## In this case we want to use the "documents" folder
   ## Save the task list out to file
   put specialFolderPath("documents") & "/tasklist.txt" into tSavePath
   put the cTaskData of me into url ("file:" & tSavePath)
end saveTaskData

on readTaskData
   ## Read the task list in from file
   put specialFolderPath("documents") & "/tasklist.txt" into tSavePath
   if there is a file tSavePath then
      put url ("file:" & tSavePath) into tTaskDetails
   end if

   ## Set the custom property of the stack to the contents of the file
   set the cTaskData of me to tTaskDetails
end readTaskData



List on card:

on mouseUp
   ## Work out which task has been selected
   ## The taskID corresponds to the line number in the list
   put word 2 of the clickline into tTaskID2
   showTaskDetails2 tTaskID2
end mouseUp

on showTaskDetails2 tTaskID2
   ## Set a custom property on the task editor card
   ## This tells it which task has been selected so the correct details can be shown
   set the cTaskID2 of card "edit 2" to tTaskID2
   go to card "edit 2"
end showTaskDetails2

这是Livecode

1 个答案:

答案 0 :(得分:0)

使用此处的所有代码,很难说出您要完成的内容,并且似乎没有任何图片可供参考。不清楚是什么构成一个&#34;项目&#34;:标题?说明?一行文字?通常,&#34;项目&#34;指的是一行文本的逗号分隔元素。

也就是说,您可以引用一个字段的特定行,并使用显式引用将其放入另一个字段,例如:

-- PLACE LINE 3 OF FIELD 1 OF CARD 1 AFTER LINE 6 OF FIELD 1 OF CARD 2
put text of field 1 of cd 1 into theText
put return & line 3 of theText after line 6 of field 1 of cd 2

要生成卡片上某物的图像(图片),您可以通过导入快照图像或将快照数据导出到要捕获的对象或区域的变量来创建快照,例如:

-- IMPORT A SNAPSHOT IMAGE FROM A GROUP ON CARD 1 WHILE ON CARD 2
import snapshot of group 1 of card 1 

-- EXPORT A SNAPSHOT OF A GROUP ON CARD 1 TO A VARIABLE AND
-- ASSIGN THE IMAGE DATA TO AN IMAGE ON CARD 2
export snapshot of group 1 of card 1 to temp
set text of image 1 to temp

请注意,如果当前卡上没有该字段,您可能无法捕获快照中字段的文本。解决方法是锁定屏幕,导航到包含要捕获的字段的卡,然后返回到起始卡并将图像数据分配给新的或现有的图像,如:

-- WHILE ON CARD 2, CAPTURE A SNAPSHOT OF A FIELD ON CARD 1
-- WITH ITS TEXT INTACT
lock screen
go card 1
export snapshot from field 1 to temp
go card 2
create image
set text of it to temp