【NX二次開發】不健全的雙擊按鈕。
阿新 • • 發佈:2020-12-10
為什麼說不健全,是因為 雙擊按鈕時會先執行單擊事件,這個後面再解決。但是模仿某公司的圖層操作工具是沒有問題了,因為這個工具執行雙擊事件時本來就需要執行單擊事件,不仔細看容易被唬住。
圖層操作工具(雙擊按鈕很奇怪。但是這個工具這樣做感覺還挺好用,趕緊學):
模仿效果:
模仿原始碼:
long int iTime = 0; int BLOCK::update_cb(NXOpen::BlockStyler::UIBlock* block) { try { if (block == button0) { //---------Enter your code here-----------clock_t start; start = clock(); long int iGetTime = start; long int itt = iGetTime - iTime; if (itt > 200) { //右側顯示圖層 list("單擊\n"); } else { //如果按鈕沒有打鉤 按鈕打鉤 右側顯示圖層打鉤//如果按鈕打鉤 按鈕取消打鉤 右側顯示圖層取消打鉤打鉤 list("雙擊\n"); } iTime = start; } } catch (exception& ex) { //---- Enter your exception handling code here ----- BLOCK::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what()); }return 0; }