2017-01-30 23 views
0

無論出於何種原因,在我使用selectOutput()選擇文件後,Processing似乎找不到回調函數。這裏是我的代碼,我正在試圖保存文件的一部分:處理程序無法從保存對話框中找到回調函數

void saveProjectDialog() { // Shows a save file dialog 
    JSONObject header = new JSONObject(); 
    header.setString("name", proj_name); 

    selectOutput(getLang("SaveDialog"), "saveProject"); 
} 

void saveProject(File selection) { // Save file dialog callback 
    if (selection == null) { 
    println("Save dialog was closed, canceled save."); 
    } else { 
    println("Saving to " + selection.getAbsolutePath()); 
    saveJSONArray(project, selection.getAbsolutePath()); 
    println("Construction saved!"); 
    } 
} 

當我選擇的道路,這是打印到控制檯:

saveProject() could not be found 

什麼是錯我的代碼?

+0

您正在使用哪種版本的Processing?我剛剛測試過3.2.3,它按預期工作 –

+0

什麼是getLang()函數和proj_name和project變量?你可以請硬編碼併發布[mcve]嗎? –

+0

'getLang()'是一個從JSON文件中獲取字符串的函數。 'proj_name'是一個用於項目名稱的字符串。 'project'是一個保存對象的JSONArray - 形狀(現在的點)。這純粹是我想要保存的數據,但我正在討論'selectOutput()'的問題。我正在使用Processing 3.2.3,我今天會更新到3.2.4。你可以在我的GitHub上看到整個代碼,回購'liquid600pgm/geometroid-pi' – lqPGM

回答

0

使用這種測試素描工作:

JSONArray project = new JSONArray(); 

String proj_name = "test"; 

void saveProjectDialog() { // Shows a save file dialog 
    JSONObject header = new JSONObject(); 
    header.setString("name", proj_name); 

    selectOutput(getLang("SaveDialog"), "saveProject"); 
} 

void saveProject(File selection) { // Save file dialog callback 
    if (selection == null) { 
    println("Save dialog was closed, canceled save."); 
    } else { 
    println("Saving to " + selection.getAbsolutePath()); 
    saveJSONArray(project, selection.getAbsolutePath()); 
    println("Construction saved!"); 
    } 
} 

void setup(){ 
    saveProjectDialog(); 
} 

String getLang(String s){ 
    return s; 
} 

仔細檢查值proj_namegetLang()結果。

相關問題