Xojo Conferences
XDCMay2019MiamiUSA

ConstructContextualMenu Examples (Real Studio network user group Mailinglist archive)

Back to the thread list
Previous thread: HTMLViewer questions
Next thread: composite windows fire events differently? or a bug?


FW: Special Valentine's Offer for Valentina - Beat the Price Increase!   -   Lynn Fredricks
  ConstructContextualMenu Examples   -   Tim Jones
   Re: ConstructContextualMenu Examples   -   Mark O'Neill
   Re: ConstructContextualMenu Examples   -   Tim Jones
   Re: ConstructContextualMenu Examples   -   Charles Yeomans
   Re: ConstructContextualMenu Examples   -   Mark O'Neill
   Re: ConstructContextualMenu Examples   -   Joe Huber
   Re: ConstructContextualMenu Examples   -   Tim Jones
   Re: ConstructContextualMenu Examples   -   Tim Jones
   Re: ConstructContextualMenu Examples   -   Tim Jones
   Re: ConstructContextualMenu Examples   -   Terry Ford
    Re: ConstructContextualMenu Examples   -   keatk comcast.net

ConstructContextualMenu Examples
Date: 29.11.07 16:53 (Thu, 29 Nov 2007 08:53:08 -0700)
From: Tim Jones
Hi Folks,

I'm refactoring some old code and I want to move my contextual menus
from the old CMM constructs to the new ContextualMenu methods
provided by the RectControl's ConstructContextualMenu and
ContextualMenuAction events. However, the "Examples" that the LR
entry point me to don't use these features and still build the menu
manually as part of the MouseDown event or use the old CMM control.

Does anyone have a working example using the new mechanism that they
would be willing to share with the list?

Thanks,
Tim

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: ConstructContextualMenu Examples
Date: 29.11.07 17:21 (Thu, 29 Nov 2007 16:21:01 +0000)
From: Mark O'Neill
Hi Tim,

On 29 Nov 2007, at 15:53, Tim Jones wrote:

> I'm refactoring some old code and I want to move my contextual menus
> from the old CMM constructs to the new ContextualMenu methods
> provided by the RectControl's ConstructContextualMenu and
> ContextualMenuAction events. However, the "Examples" that the LR
> entry point me to don't use these features and still build the menu
> manually as part of the MouseDown event or use the old CMM control.
>
> Does anyone have a working example using the new mechanism that they
> would be willing to share with the list?

I usually just do this in the MouseDown event...

if IsContextualClick then
ShowPopup
Return false
end if

...then just create a popup with MenuItems in the ShowPopup function.
Like this:

Sub ShowPopup()
dim mi as new MenuItem

// Add items
mi.Append(new MenuItem(KSomeConstant1))
mi.Append(new MenuItem(KSomeConstant2))

//Now display the menu
dim hitItem as MenuItem
hitItem = mi.PopUp

if hitItem <> nil then
DoSomething(hitItem.Text)
end if
End Sub

All the best,

Mark.
------------------------------------------------------------
RB Class
"Killer Tool Bar" - theme-based x-platform toolbar
www.rbclass.com

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: ConstructContextualMenu Examples
Date: 29.11.07 17:32 (Thu, 29 Nov 2007 09:32:10 -0700)
From: Tim Jones
On Nov 29, 2007, at 9:21 AM, Mark O'Neill wrote:

> Hi Tim,
>
> On 29 Nov 2007, at 15:53, Tim Jones wrote:
>
>> I'm refactoring some old code and I want to move my contextual menus
>> from the old CMM constructs to the new ContextualMenu methods
>> provided by the RectControl's ConstructContextualMenu and
>> ContextualMenuAction events. However, the "Examples" that the LR
>> entry point me to don't use these features and still build the menu
>> manually as part of the MouseDown event or use the old CMM control.
>>
>> Does anyone have a working example using the new mechanism that they
>> would be willing to share with the list?
>
> I usually just do this in the MouseDown event...

Thanks Mark,

This is similar to what I currently do, but the
ConstructContextualMenu and ContextualMenuAction events are supposed
to resolve potential incompatibilities with the procedure on all
platforms (according to the LR entries). That's why I'm looking for
guidance on these events versus the old way... Plus, I'm trying to
"future-proof" my projects from further deprecation of older event
models in RB (ala IsCMMClick).

Tim

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: ConstructContextualMenu Examples
Date: 29.11.07 17:39 (Thu, 29 Nov 2007 11:39:38 -0500)
From: Charles Yeomans

On Nov 29, 2007, at 11:32 AM, Tim Jones wrote:

> On Nov 29, 2007, at 9:21 AM, Mark O'Neill wrote:
>
>> Hi Tim,
>>
>> On 29 Nov 2007, at 15:53, Tim Jones wrote:
>>
>>> I'm refactoring some old code and I want to move my contextual menus
>>> from the old CMM constructs to the new ContextualMenu methods
>>> provided by the RectControl's ConstructContextualMenu and
>>> ContextualMenuAction events. However, the "Examples" that the LR
>>> entry point me to don't use these features and still build the menu
>>> manually as part of the MouseDown event or use the old CMM control.
>>>
>>> Does anyone have a working example using the new mechanism that they
>>> would be willing to share with the list?
>>
>> I usually just do this in the MouseDown event...
>
> Thanks Mark,
>
> This is similar to what I currently do, but the
> ConstructContextualMenu and ContextualMenuAction events are supposed
> to resolve potential incompatibilities with the procedure on all
> platforms (according to the LR entries). That's why I'm looking for
> guidance on these events versus the old way... Plus, I'm trying to
> "future-proof" my projects from further deprecation of older event
> models in RB (ala IsCMMClick).
>

If you're okay with Subversion, you could download the current
revision of macoslib <svn checkout http://macoslib.googlecode.com/svn/
trunk/ macoslib-read-only>. I recently rewrote the Folder Manager
example to use these events.

Charles Yeomans
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: ConstructContextualMenu Examples
Date: 29.11.07 17:55 (Thu, 29 Nov 2007 16:55:48 +0000)
From: Mark O'Neill
Hi Tim,

On 29 Nov 2007, at 16:32, Tim Jones wrote:

> This is similar to what I currently do, but the
> ConstructContextualMenu and ContextualMenuAction events are supposed
> to resolve potential incompatibilities with the procedure on all
> platforms (according to the LR entries). That's why I'm looking for
> guidance on these events versus the old way... Plus, I'm trying to
> "future-proof" my projects from further deprecation of older event
> models in RB (ala IsCMMClick).

Ah ok.

But you know the old adage - if it ain't broke, don't fix it. ;)

All the best,

Mark.
------------------------------------------------------------
RB Class
"Killer Tool Bar" - theme-based x-platform toolbar
www.rbclass.com

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: ConstructContextualMenu Examples
Date: 29.11.07 18:17 (Thu, 29 Nov 2007 09:17:40 -0800)
From: Joe Huber
At 8:53 AM -0700 11/29/07, Tim Jones wrote:
>I'm refactoring some old code and I want to move my contextual menus
>from the old CMM constructs to the new ContextualMenu methods
>provided by the RectControl's ConstructContextualMenu and
>ContextualMenuAction events.

Hi Tim

I tried doing that back when those events first came out, and for
simple cases they work fine. However they restrict what values you
can return from the mouse down event and interfered with my general
click handling code. I couldn't figure out a way to workaround that
so I went back to popping up my own menus. I've been very happy with
that approach, except when they removed IsCMM and I was worried that
I would have to go back to probelematic ContextualMenu methods.

I agree with Mark, "if it ain't broke, don't fix it. ;)"

Best regards,
Joe Huber
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: ConstructContextualMenu Examples
Date: 29.11.07 19:37 (Thu, 29 Nov 2007 11:37:41 -0700)
From: Tim Jones

On Nov 29, 2007, at 8:53 AM, Tim Jones wrote:

> ... However, the "Examples" that the LR
> entry point me to don't use these features and still build the menu
> manually as part of the MouseDown event or use the old CMM control.

Apparently I'm looking at older examples as Andre (thanks) pointed me
to the new version of the NewContextualMenus example that does use
the new mechanism.

Tim

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: ConstructContextualMenu Examples
Date: 29.11.07 20:27 (Thu, 29 Nov 2007 12:27:37 -0700)
From: Tim Jones
On Nov 29, 2007, at 11:37 AM, Tim Jones wrote:

> On Nov 29, 2007, at 8:53 AM, Tim Jones wrote:
>
>> ... However, the "Examples" that the LR
>> entry point me to don't use these features and still build the menu
>> manually as part of the MouseDown event or use the old CMM control.
>
> Apparently I'm looking at older examples as Andre (thanks) pointed me
> to the new version of the NewContextualMenus example that does use
> the new mechanism.

Ahem - I spoke too soon. While Andre's been kind enough to send me a
copy of the NewContextualMenu project, I've just downloaded the
current full package for OS X and the separate Examples package and
the old example is still in both.

Tim

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: ConstructContextualMenu Examples
Date: 30.11.07 17:19 (Fri, 30 Nov 2007 09:19:35 -0700)
From: Tim Jones
On Nov 29, 2007, at 12:27 PM, Tim Jones wrote:

> On Nov 29, 2007, at 11:37 AM, Tim Jones wrote:
>
>> On Nov 29, 2007, at 8:53 AM, Tim Jones wrote:
>>
>>> ... However, the "Examples" that the LR
>>> entry point me to don't use these features and still build the menu
>>> manually as part of the MouseDown event or use the old CMM control.
>>
>> Apparently I'm looking at older examples as Andre (thanks) pointed me
>> to the new version of the NewContextualMenus example that does use
>> the new mechanism.
>
> Ahem - I spoke too soon. While Andre's been kind enough to send me a
> copy of the NewContextualMenu project, I've just downloaded the
> current full package for OS X and the separate Examples package and
> the old example is still in both.

Imagine that - the NewContextualMenu.rbp example that I *should* have
been looking at was in a folder named "Popup Menus" instead of the
folder named "ContextualMenus". Wow, another day lost because of bad
examples and documentation...

I've made the following feature request:

http://realsoftware.com/feedback/zkvqiypo

Tim

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: ConstructContextualMenu Examples
Date: 30.11.07 19:03 (Fri, 30 Nov 2007 10:03:08 -0800)
From: Terry Ford

On Nov 30, 2007, at 8:19 AM, Tim Jones wrote:

> Imagine that - the NewContextualMenu.rbp example that I *should* have
> been looking at was in a folder named "Popup Menus" instead of the
> folder named "ContextualMenus". Wow, another day lost because of bad
> examples and documentation...
>
> I've made the following feature request:
>
> http://realsoftware.com/feedback/zkvqiypo

Tim,

Your FR has the following Description statement:

"Please have someone go through the Examples folder and clean up the
code presented so that it is both relevant and all of the code builds
and works with the current compiler."

Since every file and folder *must* have been updated on August
28,2007 12:34 PM (according to the Date Modified and Date Created
dates in the 2007 r4 examples folder) everything must be hunky-dory
there. The dates in the r3 folder are a bit more realistic, however. :-/

There is also a slight difference in the two current Contextual Menu
examples:

Both have: Date Created July 5,2006, 12:52 PM in r3.

In the Contextual Menu Folder, the name is:
NewContextualMenu.rbp

In the MenuItem Folder, the name is:
NewContextualMenus.rbp (note the added "s" in the name)

What gets me is that the Static text in the second ("s") example states:

"Contextually clicking on each of the controls (including the
GroupBox and the Window itself)..."

The problem is that Contextually clicking on the "Window itself" does
nothing. From the following, I figured it might Quit the debug run.

ConstructContextualMenu event code of Window1:
// Check to see if someone else has added any items
// to the menu. If they have, we'll put in a separator
if base.Count > 0 then
base.Append( new MenuItem( MenuItem.TextSeparator ) )
end if

// Now let's add our item, which happens to be the FileQuit
// menu item
base.Append( FileQuit )

// We're done
return true

ContextualMenuAction event code of Window1:
// We don't bother to handle any menu items here because
// the only item we added was the QuitMenuItem, which is
// handled automatically for us.

Well, I guess it works as intended but it really doesn't explain
itself very accurately.

Just another in the long list of documentation bugs that seemed to
get pushed aside for other "more pressing" matters. It does take the
engineers time away to fix old items. :-)

Terry

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: ConstructContextualMenu Examples
Date: 29.11.07 18:13 (Thu, 29 Nov 2007 17:13:43 +0000)
From: keatk comcast.net


-------------- Original message --------------
From: Tim Jones <<email address removed>>
> This is similar to what I currently do, but the
> ConstructContextualMenu and ContextualMenuAction events are supposed
> to resolve potential incompatibilities with the procedure on all
> platforms (according to the LR entries). That's why I'm looking for
> guidance on these events versus the old way...

In the past I've found those events not to fire reliably for all controls on all platforms so I put the code for those events in methods. I call the methods in the ContextualMenu events s BUT I also handle the contextual click in MouseDown myself and return true. That lets it still work for Windows (and Linux?) where the contexual menus can be brought up via the keyboard but makes sure it always works using the mouse.
> Plus, I'm trying to
> "future-proof" my projects from further deprecation of older event
> models in RB (ala IsCMMClick).

I don't think you need to worry about IsContextualClick being depricated.
There are times it is absolutely required for custom stuff. It is also useful for working around some bugs... for example in the listbox with mutiple lines selected if you try to bringing up a contextual menu to perform an action on all selected rows. it won't work.What happens is that only the row clicked on stays selected and all others are deslected. That should not happen. I use IsContextualClick in MouseDown to work around that.
- Karen
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>