Discussion:
Menu.Group property???
(too old to reply)
Bruce
2012-07-10 12:38:17 UTC
Permalink
The menu editor exposes (what looks like) a property called "Group" and
if it is set I can use that name instead of the actual menu name in the
event handler for all menu items in the same group.

This is really handy in the IDE when coupled with LAST.

But I can't set the Group "property" in code when adding menu items on
the fly?

Bruce
Tobias Boege
2012-07-10 16:57:27 UTC
Permalink
Post by Bruce
The menu editor exposes (what looks like) a property called "Group" and
if it is set I can use that name instead of the actual menu name in the
event handler for all menu items in the same group.
This is really handy in the IDE when coupled with LAST.
But I can't set the Group "property" in code when adding menu items on
the fly?
Bruce
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
I don't know where it can be read, possibly in this "property information box" you see in the
property window when editing a specific property (just below the properties listing): this is
a pseudo-property not available at runtime. It just sets the event name of all the affected controls
to the given string at creation time (wasn't there recently discussion about a $Load method which
does this job?)
If I remember correctly...

Regards,
Tobi
Bruce
2012-07-11 03:12:24 UTC
Permalink
Post by Tobias Boege
Post by Bruce
The menu editor exposes (what looks like) a property called "Group" and
if it is set I can use that name instead of the actual menu name in the
event handler for all menu items in the same group.
This is really handy in the IDE when coupled with LAST.
But I can't set the Group "property" in code when adding menu items on
the fly?
Bruce
I don't know where it can be read, possibly in this "property information box" you see in the
property window when editing a specific property (just below the properties listing): this is
a pseudo-property not available at runtime. It just sets the event name of all the affected controls
to the given string at creation time (wasn't there recently discussion about a $Load method which
does this job?)
If I remember correctly...
Regards,
Tobi
Aha! Solved it by using an observer in the class that manages my
dynamic menus.

Gambas is such a thing of beauty. :-)

Bruce


p.s. Tobi, you can see the Group name for a menu item in the .form file
as a suffix to the Menu item, e.g.
{ mnuGroup Menu
Text = ("Grouped Menu")
{ mnuGroupItem1 Menu MyGroup <----!
Name = "mnuGroup1"
Text = ("G1")
}
}
similarly for other controls
{ txtData TextArea AnotherGroup <---!
Name = "txtData"
MoveScaled(7,2,38,38)
Expand = True
}

I wonder why the IDE Group attribute was not given property status by
Benoit?
Benoît Minisini
2012-07-11 13:39:55 UTC
Permalink
Post by Bruce
Post by Tobias Boege
Post by Bruce
The menu editor exposes (what looks like) a property called "Group" and
if it is set I can use that name instead of the actual menu name in the
event handler for all menu items in the same group.
This is really handy in the IDE when coupled with LAST.
But I can't set the Group "property" in code when adding menu items on
the fly?
Bruce
I don't know where it can be read, possibly in this "property information box" you see in the
property window when editing a specific property (just below the properties listing): this is
a pseudo-property not available at runtime. It just sets the event name of all the affected controls
to the given string at creation time (wasn't there recently discussion about a $Load method which
does this job?)
If I remember correctly...
Regards,
Tobi
Aha! Solved it by using an observer in the class that manages my
dynamic menus.
Gambas is such a thing of beauty. :-)
Bruce
p.s. Tobi, you can see the Group name for a menu item in the .form file
as a suffix to the Menu item, e.g.
{ mnuGroup Menu
Text = ("Grouped Menu")
{ mnuGroupItem1 Menu MyGroup <----!
Name = "mnuGroup1"
Text = ("G1")
}
}
similarly for other controls
{ txtData TextArea AnotherGroup <---!
Name = "txtData"
MoveScaled(7,2,38,38)
Expand = True
}
I wonder why the IDE Group attribute was not given property status by
Benoit?
The "group" name is the event name as specified at object creation.

In other words, the compiler transforms

{ mnuGroup Menu
...
{ mnuGroupItem1 Menu MyGroup

into

mnuGroupItem1 = new Menu(menuGroup) As "MyGroup"

Look at the documentation of the NEW instruction.

Regards,
--
Benoît Minisini
Tobias Boege
2012-07-11 15:04:24 UTC
Permalink
Post by Bruce
Aha! Solved it by using an observer in the class that manages my
dynamic menus.
Gambas is such a thing of beauty. :-)
You can do it without an Observer, too. Observers duplicate events to there could be some overhead
with this solution (unless that behaviour is desired) - besides the memory used for the Observer
object: Just re-attach those objects that you want to 'Group' to their parents with the same event
name:

For Each hObj In myGroupObjs
Object.Attach(hObj, Object.Parent(hObj), sNewGroup)
Next

This could prevent former event handlers to interfere... (Just guessing. It's a matter of your
application)

Regards,
Tobi
Bruce
2012-07-12 01:20:46 UTC
Permalink
(Slightly out of line, I'm just trying to tie the above two responses
together)
Post by Benoît Minisini
The "group" name is the event name as specified at object creation.
In other words, the compiler transforms
{ mnuGroup Menu
...
{ mnuGroupItem1 Menu MyGroup
into
mnuGroupItem1 = new Menu(menuGroup) As "MyGroup"
Look at the documentation of the NEW instruction.
Regards,
--
Benoît Minisini
Ah! As usual, I need to listen to my own maxims. I have now installed a
large sign above my monitor saying "Read EVERY word of the help
page!" :-)

And, that of course eliminates the need for an explicit observer.
Post by Benoît Minisini
Post by Tobias Boege
You can do it without an Observer, too. Observers duplicate events to there could be some overhead
with this solution (unless that behaviour is desired) - besides the memory used for the Observer
object: Just re-attach those objects that you want to 'Group' to their parents with the same event
For Each hObj In myGroupObjs
Object.Attach(hObj, Object.Parent(hObj), sNewGroup)
Next
This could prevent former event handlers to interfere... (Just guessing. It's a matter of your
application)
Regards,
Tobi
Now, that is rather interesting. I made a "recentfiles" library and a
tester that are attached, (this was a lot simpler than trying to build a
stand-alone model of our real dynamic menu need*).

I think I see what you are getting and maybe that approach would
simplify the at handling necessary in the client form, but I can't quite
get it to operate (still looking at the help page). If you can spare
the time, would you take a look at the attached and comment on whether
it would simplify the client code requirements.

regards
Bruce


* for the sake of any interest, we have a gridview listing horses at
upcoming auctions. It has a fanciful "rating" based on the known
previous performances of the horse and a bunch of statutory events that
can occur in its history. The user wishes to look at the history of a
specific in more detail. We have tried various ways to display this with
varying success as the events (things like prior race performances,
barrier trials, vet examinations, notified gear changes, gelding, etc
etc etc) are quite different in their characteristics. In the main, the
user wants to see a summary of the history and then drill down into one
of those events. On average there are about a dozen or so events per
horse of interest to our demographic, but the number could be one to
several dozen. So the idea is to put a popup menu on the gridview which
would be populated dynamically depending on the current selected row.
This would display the horses event history and allow an event to be
selected, whereupon a popup window would display the details of that
event.
Bruce
2012-07-12 01:21:23 UTC
Permalink
(Slightly out of line, I'm just trying to tie the above two responses
together)
Post by Benoît Minisini
The "group" name is the event name as specified at object creation.
In other words, the compiler transforms
{ mnuGroup Menu
...
{ mnuGroupItem1 Menu MyGroup
into
mnuGroupItem1 = new Menu(menuGroup) As "MyGroup"
Look at the documentation of the NEW instruction.
Regards,
--
Benoît Minisini
Ah! As usual, I need to listen to my own maxims. I have now installed a
large sign above my monitor saying "Read EVERY word of the help
page!" :-)

And, that of course eliminates the need for an explicit observer.
Post by Benoît Minisini
Post by Tobias Boege
You can do it without an Observer, too. Observers duplicate events to there could be some overhead
with this solution (unless that behaviour is desired) - besides the memory used for the Observer
object: Just re-attach those objects that you want to 'Group' to their parents with the same event
For Each hObj In myGroupObjs
Object.Attach(hObj, Object.Parent(hObj), sNewGroup)
Next
This could prevent former event handlers to interfere... (Just guessing. It's a matter of your
application)
Regards,
Tobi
Now, that is rather interesting. I made a "recentfiles" library and a
tester that are attached, (this was a lot simpler than trying to build a
stand-alone model of our real dynamic menu need*).

I think I see what you are getting and maybe that approach would
simplify the at handling necessary in the client form, but I can't quite
get it to operate (still looking at the help page). If you can spare
the time, would you take a look at the attached and comment on whether
it would simplify the client code requirements.

regards
Bruce


* for the sake of any interest, we have a gridview listing horses at
upcoming auctions. It has a fanciful "rating" based on the known
previous performances of the horse and a bunch of statutory events that
can occur in its history. The user wishes to look at the history of a
specific in more detail. We have tried various ways to display this with
varying success as the events (things like prior race performances,
barrier trials, vet examinations, notified gear changes, gelding, etc
etc etc) are quite different in their characteristics. In the main, the
user wants to see a summary of the history and then drill down into one
of those events. On average there are about a dozen or so events per
horse of interest to our demographic, but the number could be one to
several dozen. So the idea is to put a popup menu on the gridview which
would be populated dynamically depending on the current selected row.
This would display the horses event history and allow an event to be
selected, whereupon a popup window would display the details of that
event.

Continue reading on narkive:
Loading...