Verified Commit 3471d52d authored by Camil Staps's avatar Camil Staps 🚀

Add Id and OnClickHandler for MenuItem

parent 1060caaa
...@@ -3,7 +3,7 @@ definition module Electron.Menu ...@@ -3,7 +3,7 @@ definition module Electron.Menu
from Data.Map import :: Map from Data.Map import :: Map
from ABC.Interpreter.JavaScript import :: JSVal, generic gToJS from ABC.Interpreter.JavaScript import :: JSVal, generic gToJS
from iTasks.UI.Tune import class tune from iTasks.UI.Tune import class tune
from Electron.Types import :: EnabledDisabled from Electron.Types import :: EnabledDisabled, :: Id, :: OnClickHandler
:: Menu :== [MenuItem] :: Menu :== [MenuItem]
...@@ -14,6 +14,8 @@ from Electron.Types import :: EnabledDisabled ...@@ -14,6 +14,8 @@ from Electron.Types import :: EnabledDisabled
derive gToJS MenuItem derive gToJS MenuItem
instance tune Id MenuItem
:: SubMenu =: SubMenu Menu :: SubMenu =: SubMenu Menu
instance tune SubMenu MenuItem instance tune SubMenu MenuItem
...@@ -41,3 +43,5 @@ instance tune EnabledDisabled MenuItem ...@@ -41,3 +43,5 @@ instance tune EnabledDisabled MenuItem
:: MenuItemType = Checkbox | Radio :: MenuItemType = Checkbox | Radio
instance tune MenuItemType MenuItem instance tune MenuItemType MenuItem
instance tune OnClickHandler MenuItem
...@@ -28,6 +28,10 @@ withOption key val mi = case mi of ...@@ -28,6 +28,10 @@ withOption key val mi = case mi of
-> CustomMenuItem ('Data.Map'.put key (toJS val) opts) -> CustomMenuItem ('Data.Map'.put key (toJS val) opts)
-> withOption key val (toCustomMenuItem mi) -> withOption key val (toCustomMenuItem mi)
instance tune Id MenuItem
where
tune (Id id) mi = withOption "id" id mi
instance tune SubMenu MenuItem instance tune SubMenu MenuItem
where where
tune (SubMenu menu) mi = withOption "submenu" menu mi tune (SubMenu menu) mi = withOption "submenu" menu mi
...@@ -58,3 +62,7 @@ where ...@@ -58,3 +62,7 @@ where
toString mit = case mit of toString mit = case mit of
Checkbox -> "checkbox" Checkbox -> "checkbox"
Radio -> "radio" Radio -> "radio"
instance tune OnClickHandler MenuItem
where
tune (OnClick h) mi = withOption "click" h mi
definition module Electron.Types definition module Electron.Types
from ABC.Interpreter.JavaScript import :: JSFun, :: JSVal
:: EnabledDisabled = Enabled | Disabled :: EnabledDisabled = Enabled | Disabled
:: Id =: Id String
:: OnClickHandler =: OnClick JSFun
implementation module Electron.Types implementation module Electron.Types
import ABC.Interpreter.JavaScript
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment