2015-02-06 93 views
1

不能發佈圖片的又一讓我知道,如果需要的話在兩個列表之間移動可編輯項目?

感謝您的幫助!這樣做的目的是能夠編輯一張卡上的列表並將其移動到另一張卡上的列表中。我也試圖讓物品移動也包含可編輯的時間,可編輯的描述和對象的圖片。所有這些都不在名單上顯示,只是標題。如果我需要解釋更多,請告訴我。我對此很新穎。

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

+0

你能解釋一下你想從哪裏到哪個地方移動什麼樣的圖片? – Mark 2015-02-07 12:35:16

回答

0

爲什麼你保存性能如此多的數據目前尚不清楚給我。一旦數據進入現場,您可以將其保留在那裏。當您需要將數據從一張卡上的字段移動到另一張卡上的字段時,可以直接進行。例如,假設您想要的領域「標題」和卡1的「說明」的內容複製到相同的字段上卡2

// this handler is in the card script of card 2 
on preOpenCard 
    put fld "Title" of cd 1 into fld "Title" 
    put fld "Description" of cd 1 into fld "Description" 
end preOpenCard 

這是你所需要的。在這種情況下不需要定製屬性。

+0

好吧,當我說你得到**當你需要將數據從一張卡上的一個字段移動到另一張卡上的一個字段時,你可以直接這樣做**但是有沒有辦法讓我隱藏文字顯示在列表上,但顯示在編輯卡上?我很難理解處理程序之間的關係。但無論如何,我希望列表中顯示標題的不同項目以及與標題連接時隱藏的其他文本和圖片,但是在單獨的卡片上,隱藏的文本和圖片會填充相應的字段,並且可以是編輯。 – SirDerp 2015-02-09 19:57:51

+0

這是一個很長的句子,@SirDerp。你能逐步描述你想要的嗎?您可以更改您的問題並添加步驟。您可以將數據從一張卡的隱藏字段複製到另一張卡的可見字段中,方法與我答案中處理程序中顯示的方式相同。對於控件,卡片,堆棧和處理程序之間的關係,您可能需要提出一個新問題。 – Mark 2015-02-10 12:28:56

+0

有沒有辦法讓我發送你的應用程序的圖片?它的皮膚現在,但我需要得到的代碼工作。這將有助於理解應用程序的流程。 – SirDerp 2015-02-10 19:31:21

相關問題