(ql:quickload '(lorem-ipsum qtools qtcore qtgui)) (named-readtables:in-readtable :qtools) (in-package #:cl+qt) (define-widget my-editor (qtextedit) ((other-widget :initform (q+:make-qwidget)))) (define-override (my-editor context-menu-event) (event) (let* ((position (q+:pos event)) (cursor (q+:cursor-for-position my-editor position)) (block-number (q+:block-number cursor))) (print block-number) (call-next-qmethod) (with-finalizing ((menu (q+:create-standard-context-menu my-editor))) (q+:exec menu (q+:global-pos event))) (q+:show other-widget) (setf (q+:focus other-widget) 0) (q+:hide other-widget))) (defun test () (with-main-window (editor 'my-editor) (dotimes (i 5) (q+:append editor (lorem-ipsum:paragraph :prologue nil)))))