Re: Menus and components

2017-12-18 Thread Tim Nevels via 4D_Tech
On Dec 18, 2017, at 2:00 PM, Jeremy Roussak wrote:

> Your last line is the key: according to the documentation, nothing has 
> changed, but when I run the code, everything has changed.
> 
> So it seems that if I want to have component display a form while keeping the 
> host’s menus visible and working, I must create all the host’s menus using 
> code rather than using the toolbox Menu editor.
> 
> Can that really be right?

I’ve done some work with components that have forms and their own menu bar. It 
is a tricky area for sure. 

One problem I ran into was from the component I wanted to open a window, use 
DIALOG command and to have a custom menu bar for this new window. So from the 
host I would start a new process and then call a component method that would do 
this work. 

This is running in a new process, but the method “ShowEditor” is from the 
component and it is of course shared so it can be called fro the host. Here is 
sample code:

SET MENU BAR(“Editor Menu”)
OPEN WINDOW
DIALOG

This worked fine form some host database, but other it didn’t work. The menu 
bar was screwed up. I finally figured out what was going and how to fix it. 

The problem was SET MENU BAR command using a menu bar name for a menu created 
in Design in the Toolbox. Even though I was referencing it by name it was still 
internally somehow referencing the menu bar number. So if the host had a menu 
bar with the same number “Editor Menu” in the component database there were 
problems. 

One workaround was to create many many dummy menu bars in the component from 
the Toolbox. I needed to get the menu bar number high enough so it would not 
have a conflict with any menu bars in the host database. That worked, but was a 
big pain-in-the-ass because I use a lot of menu bars in my applications and all 
created with the Toolbox. So I had to create like 50 blank menu bars in the 
component to make this work. 

Then I got the idea to do this:

C_TEXT($menuRef_t)
$menuRef_t:=Create menu(“Editor Menu")
SET MENU BAR($menuRef_t)

Problem solved. No need to create dummy menu bars in the component. 

So maybe you could use this technique for your application. Create the menu in 
the host and get a $menuRef_t. Then pass $menuRef_t to your component. From the 
component context you do SET MENU BAR($menuRef_t). I think $menuRef_t is sort 
of like a pointer or a memory location reference. So that would allow you to 
share a menubar from the host, created in the toolbox, with a component. 

Tim


Tim Nevels
Innovative Solutions
785-749-3444
timnev...@mac.com


**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Menus and components

2017-12-18 Thread Jeremy Roussak via 4D_Tech
Miyako,

You’re quite right: the documentation is clear. However, it was every bit as 
clear in v14, and what I am doing worked.

I’m not being quite as naughty as you might think. My main host database 
handles my practice (I’m a lawyer). It has a self-contained unit within it 
which displays a dialog and does various semi-complex calculations that people 
like me find useful. It doesn’t interact in any way with any other part of the 
database and doesn’t use any of its tables. 

Colleagues saw it and thought it would be useful for them, so I hived it off 
into a component. I can build that component into a very simple shell, which 
offers just the calculator, and give it to them; and I can continue to include 
it as a module in my main application. I can develop it in only one place, 
which is handy.

It doesn’t need any of the host menus to be available. It’s just desirable that 
all the host menus are in fact available.

As John DeSoi has pointed out, it is in fact still possible to do what I want 
to do in the way he suggests: get the host to install the menu bar via a 
callback and make sure that any method identified in the menu editor is flagged 
as shared. Thanks, John!

Jeremy


Jeremy Roussak
j...@mac.com



> On 18 Dec 2017, at 00:44, Keisuke Miyako via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
>> The form was set in v14 to have an active menu bar, called “Main”. The 
>> component doesn’t have a menu bar “Main” but each parent application does.
> 
> I am surprised that this even worked.
> 
> the documentation is quite clear that menu bars created vis the Tool Box Menu 
> Editor are not shared,
> so the activate menu bar of a component form can only be loaded from its own 
> stock of menu bars.
> 
> if I needed a generic component dialog that "inherits" the host's menu bar,
> I would call SET MENU BAR in the host context before calling the component's 
> dialog method,
> or else Get/SET the menu bar in the form's On Load event.
> 
> it simply feels wrong for a component to expect a specific menu bar name in 
> its property list.
> such implicit linkage, even if it worked, should be discouraged.
> the active menu bar of a component should be a menu available locally, or 
> else undefined.
> 
> if it "stopped working" then it sounds like a bug fix.

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Menus and components

2017-12-18 Thread John DeSoi via 4D_Tech
I just realized I left out a key detail. Whenever I was mixing host and 
component menus on the same menu bar, 4D would crash when I quit. I solved this 
by duplicating the host menu in code before appending the component menus. This 
is probably why all the host methods must be shared.

John DeSoi, Ph.D.


> On Dec 18, 2017, at 7:59 AM, John DeSoi via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> This is working for me in version 16 (16.3). I set the main menu bar with a 
> callback to the host. Then the component appends some additional menus 
> created in the component to the host main menu. The appended menus are 
> created with code. The component form has a completely empty menu associated 
> with it and "Active Menu Bar" checked.
> 
> I just noticed that even though the component called the host to set the main 
> menubar, all of the host menu methods must have the "Shared" property set for 
> the menu item to work. I get a error that the method is not found otherwise.

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Menus and components

2017-12-18 Thread John DeSoi via 4D_Tech


> On Dec 17, 2017, at 1:01 PM, Jeremy Roussak via 4D_Tech 
> <4d_tech@lists.4d.com> wrote:
> 
> In v16, things have changed. The parent menu bar doesn’t appear; and if I 
> make it appear, by supplying a callback routine in the parent which calls SET 
> MENU BAR(“Main”), while the menu bar and its associated menus do appear, 
> nothing happens when I select anything.

This is working for me in version 16 (16.3). I set the main menu bar with a 
callback to the host. Then the component appends some additional menus created 
in the component to the host main menu. The appended menus are created with 
code. The component form has a completely empty menu associated with it and 
"Active Menu Bar" checked.

I just noticed that even though the component called the host to set the main 
menubar, all of the host menu methods must have the "Shared" property set for 
the menu item to work. I get a error that the method is not found otherwise.

John DeSoi, Ph.D.


**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Menus and components

2017-12-17 Thread Keisuke Miyako via 4D_Tech
> The form was set in v14 to have an active menu bar, called “Main”. The 
> component doesn’t have a menu bar “Main” but each parent application does.

I am surprised that this even worked.

the documentation is quite clear that menu bars created vis the Tool Box Menu 
Editor are not shared,
so the activate menu bar of a component form can only be loaded from its own 
stock of menu bars.

if I needed a generic component dialog that "inherits" the host's menu bar,
I would call SET MENU BAR in the host context before calling the component's 
dialog method,
or else Get/SET the menu bar in the form's On Load event.

it simply feels wrong for a component to expect a specific menu bar name in its 
property list.
such implicit linkage, even if it worked, should be discouraged.
the active menu bar of a component should be a menu available locally, or else 
undefined.

if it "stopped working" then it sounds like a bug fix.



**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Menus and components

2017-12-17 Thread Arnaud de Montard via 4D_Tech

> Le 17 déc. 2017 à 20:01, Jeremy Roussak via 4D_Tech <4d_tech@lists.4d.com> a 
> écrit :
> 
> I’m changing from v14 to v16 and am getting confused.
> 
> I have a component which is used in two applications. It displays and works 
> with a multi-page form which is entirely self-contained. The form was set in 
> v14 to have an active menu bar, called “Main”. The component doesn’t have a 
> menu bar “Main” but each parent application does.[...]

Hi Jeremy, 
it seems it depends on the host menubar "nature":


in "Unshared objects"
  Menus and menu bars created via the Menu editor

in "Shared objects"
  Menus and menu bars using the ID returned by the Create menu command

But it does not explain the change, v14 and v16 docs seem identical about this. 

-- 
Arnaud de Montard 


**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Menus and components

2017-12-17 Thread Jeremy Roussak via 4D_Tech
I’m changing from v14 to v16 and am getting confused.

I have a component which is used in two applications. It displays and works 
with a multi-page form which is entirely self-contained. The form was set in 
v14 to have an active menu bar, called “Main”. The component doesn’t have a 
menu bar “Main” but each parent application does.

In v14, this worked fine. The form appeared, the menus (from the parent 
application) were present and they worked.

In v16, things have changed. The parent menu bar doesn’t appear; and if I make 
it appear, by supplying a callback routine in the parent which calls SET MENU 
BAR(“Main”), while the menu bar and its associated menus do appear, nothing 
happens when I select anything.

I’m obviously missing something very fundamental. Is what I want to do, namely 
use the parent’s menu bar, possible, or under v16 are selections executed in 
the component’s context rather than in the parent’s?

Jeremy


Jeremy Roussak
j...@mac.com



**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**