))))
(def layered-method render-component-stub :in xhtml-layer :after ((-self- context-menu/widget))
(bind (((:read-only-slots id) -self-)
(parent-id (id-of (parent-component-of -self-))))
;; TODO due to the custom :js this hinders the optimization in render-action-js-event-handler
(render-action-js-event-handler "oncontextmenu" parent-id (make-action
(setf (lazily-rendered-component? -self-) #f))
:js (lambda (href)
`js(wui.io.lazy-context-menu-handler event connection ,href ,id ,parent-id))
:one-shot #t :stop-event #t)
;; another alternative, but left clicking anything will force the context menu to download, and i think :xhr-sync true is also missing...
#+nil
(render-action-js-event-handler "onmousedown" parent-id (make-action
(setf (to-be-rendered-component? -self-) #t))
:subject-dom-node parent-id
:one-shot #t :sync #t)))
;;;;;;
;;; menu-item/widget
(def (component e) menu-item/widget (standard/widget content/component menu-items/mixin)
()
(:documentation "A MENU-ITEM/WIDGET is an intermediate or leaf COMPONENT in a MENU-HIERARCHY."))
(def (macro e) menu-item/widget ((&rest args &key &allow-other-keys) content &body menu-items)
`(make-instance 'menu-item/widget ,@args :content ,content :menu-items (flatten (list ,@menu-items))))
(def (function e) make-menu-item (content &rest menu-items)
(bind ((menu-items (flatten menu-items)))
(when (or menu-items
content)
(make-instance 'menu-item/widget
:content content
:menu-items (mapcar (lambda (menu-item)
(if (typep menu-item 'menu-item/widget)
menu-item
(make-menu-item menu-item)))
menu-items)))))
(def (function e) make-submenu-item (content &rest menu-items)
(bind ((menu-items (flatten menu-items)))
(when menu-items
(make-menu-item content menu-items))))
(def render-xhtml menu-item/widget
(bind (((:read-only-slots menu-items id style-class custom-style content) -self-))
(if menu-items
(bind ((popup-id (generate-unique-component-id)))
(render-dojo-widget (popup-id)
(render-content-for -self-))
,(render-dojo-widget (id)
)>))
(when (visible-component? content)
(render-dojo-widget (id)
(when (typep content 'command/widget)
(render-command-onclick-handler content id)))))))
(def function render-show-context-menu-command-for (component)
(declare (ignore component))
;; TODO: add js to really show the menu
(render-component (icon/widget show-context-menu :label nil)))
(def method command-position ((self menu-item/widget))
(if (menu-items-of self)
most-positive-fixnum
(command-position (content-of self))))
;;;;;;
;;; menu-item-separator/widget
(def (component e) menu-item-separator/widget (standard/widget)
()
(:documentation "A MENU-ITEM-SEPARATOR/WIDGET is a leaf COMPONENT in the MENU-HIERARCHY separating other MENU-ITEM/WIDGETs."))
(def (macro e) menu-item-separator/widget (&rest args &key &allow-other-keys)
`(make-instance 'menu-item-separator/widget ,@args))
(def render-xhtml menu-item-separator/widget
(bind (((:read-only-slots id) -self-))
(render-dojo-widget (id)
)))