How to control what context menu will be shown?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to control what context menu will be shown?

Maxim Fridental
Hello,

I'll give an example first. I have a DialogView with a MultilineTextEdit on
it. I want to show my context menu for the dialog, but leave default window
processing for the text edit control (i.e. I want the standard windows
context menu for text controls - cut, copy, paste - to be shown).
I've found the method View>>queryContextMenu. In its current implementation
(DPRO5.03) it takes the parents context menu if our context menu isNil. The
first question is: why we are inheriting the context menu from the parent
view only? Why not from the parents parent if the parents context menu isNil
and so on? The second question is: do we have a possibility to override this
behavior and set default window processing for any particular View? Thanks.

Best regards
Maxim Fridental


Reply | Threaded
Open this post in threaded view
|

Re: How to control what context menu will be shown?

Blair McGlashan
"Maxim Fridental" <[hidden email]> wrote in message
news:b5mpvh$29pcn9$[hidden email]...
> Hello,
>
> I'll give an example first. I have a DialogView with a MultilineTextEdit
on
> it. I want to show my context menu for the dialog, but leave default
window
> processing for the text edit control (i.e. I want the standard windows
> context menu for text controls - cut, copy, paste - to be shown).
> I've found the method View>>queryContextMenu. In its current
implementation
> (DPRO5.03) it takes the parents context menu if our context menu isNil.
The
> first question is: why we are inheriting the context menu from the parent
> view only? Why not from the parents parent if the parents context menu
isNil
> and so on?

Its a bug in the #queryContextMenu implementation - it should recursively
invoke itself to chain up through the parents.

>...The second question is: do we have a possibility to override this
> behavior and set default window processing for any particular View?
Thanks.

I presume you mean can one suppress the inheritance of the parent context
menu in order to use a control's own context menu?
Without subclassing the view, I think the answer is no.

Regards

Blair


Reply | Threaded
Open this post in threaded view
|

Re: How to control what context menu will be shown?

Maxim Fridental
Hello,

"Blair McGlashan" <[hidden email]> wrote in message
news:b5nco7$2b05uq$[hidden email]...
> I presume you mean can one suppress the inheritance of the parent context
> menu in order to use a control's own context menu?
> Without subclassing the view, I think the answer is no.
It's quiet surprising for me, that nobody has needed that functionality
before. To close the question, here is a hack that resolves the problem.
Just set 'DefaultMenu new' as a context menu for all TextEdit views.

"Filed out from Dolphin Smalltalk 2002 release 5.00"!

Menu subclass: #DefaultMenu
 instanceVariableNames: ''
 classVariableNames: ''
 poolDictionaries: 'Win32Constants'
 classInstanceVariableNames: ''!
DefaultMenu guid: (GUID fromString:
'{34090861-5B13-49A4-A554-24235DC76EAA}')!
DefaultMenu comment: ''!
!DefaultMenu categoriesForClass!Unclassified! !
!DefaultMenu methodsFor!

showIn: aView position: aPoint
 aView
  defaultWindowProcessing: WM_CONTEXTMENU
  wParam: aView handle
  lParam: (POINTL fromPoint: aPoint) asDword! !
!DefaultMenu categoriesFor: #showIn:position:!public! !

Best Regards,
Maxim Fridental