看板 MATLAB 關於我們 聯絡資訊
在 matlab 中, 指定 GUI元件 所管轄的 GUI事件 為 fun 後, 當 該GUI元件 的 GUI事件 一發生 matlab 就會呼叫 fun(x, y), x 與 y 是由 matlab 自動傳入的, x 是 GUI元件 的 handle, y 是選擇性參數,看該元件與該事件而決定要不傳。 目前的例子中: GUI元件為 figure, GUI事件為 WindowButtonMotionFcn(x, y), x 為 figure 的 handle, y 為 [], 所以 get(x, 'CurrentPoint') 為取得 figure 中的 CurrentPoint 屬性。 ※ 引述《InoueToro (InoueToro)》之銘言: : 大大您好 : 不好意思, 小弟GUI剛入門... : 能否請您解釋一下這語法 : @(x, y) disp(get(x, 'CurrentPoint')) : get一般不是去獲取某gca或gco的子屬性值嗎@@? : get(x 是指?? : 謝謝教導 : ※ 引述《mp19990920 (郝渴連)》之銘言: : : to jatj大: : : mouseoverfcn是啥啊??? : : 我在matlab的help中都找不到耶! : : to 原PO: : : 您可以用以下的程式來修改 : : step 1 產生出一張圖 : : hFig = figure; : : step 2 建立滑鼠移動時要呼叫的函數 : : move = @(x, y) disp(get(x, 'CurrentPoint')); : : step 3 把滑鼠移動要呼叫的函數指定給一開始產生的圖 : : set(hFig, 'WindowButtonMotionFcn', move); : : 此時您的滑鼠在圖上移動時, : : command window 就會把滑鼠的位置顯示出來。 : : 總結: : : figure 內有兩個參數, : : 您可以用 inspect(hFig) 來觀察, : : 一個是 CurrentPoint 一個是 WindowButtonMotionFcn, : : CurrentPoint 會自己更新我們動不了他, : : WindowButtonMotionFcn是滑鼠在移動的時候 matlab 會自己呼叫他。 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 111.67.61.203
InoueToro:請問在get(x時, 為何x已指定是figure了? 跟@的用法有關? 11/10 17:25
mp19990920:建議您在 help 中搜尋 GUI 與 funciton handle 吧 11/11 01:59
InoueToro:好 我再念一下書 謝謝 11/11 21:39