SOLVED How to create a left-aligned group in the menu.

I want to create a left-aligned group in the menu. I found GroupBeginInMenuLine() in the official documentation, but it can only align the group to the left.
I searched for this problem and it seems that this function cannot be used to create a left-aligned group.
Is there any other way to create a left-aligned group? what should I do?
The above is a plug-in that uses GroupBeginInMenuLine(), and the following is a plug-in that implements left-aligned by others.
b6cb34ff-043c-4991-bf66-b83894bc681c-image.png

Thank,
aimidi

Hi @AiMiDi,

so, if I do understand your example correctly, you want to place your custom tab element gadget via GroupBeginInMenuLine on the height of the menu, but at the same time have its content aligned to the left, i.e., the space which is normally occupied by the "normal" menu of a dialog.

When you look at the documentation of GroupBeginInMenuLine, you will see that it is built into the method to align its content to the right of the menu space. The only thing you could try to do is use BFH_SCALEFIT flags to try to consume all the space from the right to the left. Which I tried for you and does not work. I also tried using a dummy element for pushing the content to the left, which works on a technical level, but effectively introduces so many other problems that it is not useable either (with a lot of dedication, one MIGHT be able to push that hack, but this is obviously not the intended use of the SDK and therefore out of scope of support).

So, in the end this is simply not possible, as it goes against the purpose of GroupBeginInMenuLine of showing a smaller element on the right side of the menu, e.g., a search field. You will have to move your tab-interface into the regular layout of the dialog.

Cheers,
Ferdinand

The code is used to look at the method:

"""
"""

import c4d

class TabMenuDialog(c4d.gui.GeDialog):
    """
    """
    def CreateLayout(self):
        """
        """
        self.SetTitle("Tabulated Menu Dialog")

        documentNode = c4d.documents.GetFirstDocument()
        commonFlag = c4d.BFH_LEFT | c4d.BFH_SCALEFIT
        self.MenuSubBegin("File")
        self.MenuSubEnd()
        self.GroupBeginInMenuLine()
        self.GroupBegin(1000, commonFlag , 0, 1, "", 0, 0, 0)

        self.TabGroupBegin(1001, commonFlag, c4d.TAB_TABS)
        ID_DYNMAIC, i = 2000, 0

        while documentNode:
            documentName = documentNode.GetDocumentName()
            firstObject = documentNode.GetFirstObject()
            firstObjectName = firstObject.GetName() if firstObject else "None"
            self.GroupBegin(ID_DYNMAIC + i, c4d.BFH_LEFT , 0, 1, documentName)
            self.AddStaticText(ID_DYNMAIC + i + 1, c4d.BFH_LEFT, 0, 10, 
                               firstObjectName, c4d.BORDER_NONE)
            self.GroupEnd()
            documentNode = documentNode.GetNext()
            ID_DYNMAIC += 2
        self.GroupEnd()
        
        # Will push stuff to the left
        self.AddStaticText(ID_DYNMAIC + 1, commonFlag, 1000, 10, "Filler", c4d.BORDER_NONE)
        self.GroupEnd()
        self.GroupEnd()
        return True

def main():
    """
    """
    global myDialog
    myDialog = TabMenuDialog()
    myDialog.Open(c4d.DLG_TYPE_ASYNC)

if __name__ == '__main__':
    main()

Hello @AiMiDi,

thank you for reaching out to us. I have a bit troubles understanding the intentions of your posting. For once it would be important to know where you are defining your dialog - as a resource file or in code? Secondly, you talk about menus but show the image of a TAB gadget if I am not mistaken. And finally, you are asking for left aligned gadget, but that is the default. So, I assume you want to align a menu to the right?

Menus itself cannot be aligned to the right, but there is GeDialog::GroupBeginInMenuLine() with which you can open a second group within the dialog menu so to speak, which is meant to place elements like a search bar or similar things. This will operate right-side aligned.

In case I have misunderstood your question, I would have to ask you to restate it.

Cheers,
Ferdinand

I want to add a few TAB gadgets to the menu bar of the window to make them aligned to the left (left-side aligned, starting from the left). Or I want to make my TAB look like 074d8c6c-ac98-42a8-8a15-0e02e26a236a-image.png
I created the layout with code. Below is the code.

Bool DocTabDialog::CreateLayout() {
	this->SetTitle("DocTab"_s);
	BaseDocument* doc = GetFirstDocument();
	GroupBeginInMenuLine();
	GroupBegin(1000, BFH_LEFT , 0, 1, ""_s, 0, 0, 0);
	GroupSpace(0, 0);
	while (doc != nullptr)//Traverse all the items and add them to the label
	{
		Int32 Index = doc_tab_dialog_arr.GetCount();
		DocTabUserArea* doc_tab_user_area = new DocTabUserArea(doc, DOC_TAB);
		C4DGadget* const userAreaGadget = this->AddUserArea(10000 + Index, BFH_LEFT , 160, 14);
		if (userAreaGadget != nullptr)
			this->AttachUserArea((*doc_tab_user_area), userAreaGadget);
		iferr(doc_tab_dialog_arr.Append(doc_tab_user_area))return false;
		doc = doc->GetNext();
	}
	addDocTab = new DocTabUserArea(nullptr, ADD_TAB);
	C4DGadget* userAreaGadget = this->AddUserArea(1001, BFH_LEFT, 30, 14);//Add "Add Tab" button
	if (userAreaGadget != nullptr)
		this->AttachUserArea((*addDocTab), userAreaGadget);
	recDocTab = new DocTabUserArea(nullptr, REC_DOC);
	userAreaGadget = this->AddUserArea(1002, BFH_LEFT, 30, 14);//Add "History document" button
	if (userAreaGadget != nullptr)
		this->AttachUserArea((*recDocTab), userAreaGadget);
	GroupEnd();
	GroupEnd();
	return true;
}

See more here.

Thanks,
Aimidi

Hello @ferdinand
Can you understand what I said? Do I need to add anything?

Thanks,
Aimidi

Hello @AiMiDi,

thank you for your reply. No, you do not need to add anything. I think I do understand your goals now. I will answer here today or tomorrow.

Cheers,
Ferdinand

Hi @AiMiDi,

so, if I do understand your example correctly, you want to place your custom tab element gadget via GroupBeginInMenuLine on the height of the menu, but at the same time have its content aligned to the left, i.e., the space which is normally occupied by the "normal" menu of a dialog.

When you look at the documentation of GroupBeginInMenuLine, you will see that it is built into the method to align its content to the right of the menu space. The only thing you could try to do is use BFH_SCALEFIT flags to try to consume all the space from the right to the left. Which I tried for you and does not work. I also tried using a dummy element for pushing the content to the left, which works on a technical level, but effectively introduces so many other problems that it is not useable either (with a lot of dedication, one MIGHT be able to push that hack, but this is obviously not the intended use of the SDK and therefore out of scope of support).

So, in the end this is simply not possible, as it goes against the purpose of GroupBeginInMenuLine of showing a smaller element on the right side of the menu, e.g., a search field. You will have to move your tab-interface into the regular layout of the dialog.

Cheers,
Ferdinand

The code is used to look at the method:

"""
"""

import c4d

class TabMenuDialog(c4d.gui.GeDialog):
    """
    """
    def CreateLayout(self):
        """
        """
        self.SetTitle("Tabulated Menu Dialog")

        documentNode = c4d.documents.GetFirstDocument()
        commonFlag = c4d.BFH_LEFT | c4d.BFH_SCALEFIT
        self.MenuSubBegin("File")
        self.MenuSubEnd()
        self.GroupBeginInMenuLine()
        self.GroupBegin(1000, commonFlag , 0, 1, "", 0, 0, 0)

        self.TabGroupBegin(1001, commonFlag, c4d.TAB_TABS)
        ID_DYNMAIC, i = 2000, 0

        while documentNode:
            documentName = documentNode.GetDocumentName()
            firstObject = documentNode.GetFirstObject()
            firstObjectName = firstObject.GetName() if firstObject else "None"
            self.GroupBegin(ID_DYNMAIC + i, c4d.BFH_LEFT , 0, 1, documentName)
            self.AddStaticText(ID_DYNMAIC + i + 1, c4d.BFH_LEFT, 0, 10, 
                               firstObjectName, c4d.BORDER_NONE)
            self.GroupEnd()
            documentNode = documentNode.GetNext()
            ID_DYNMAIC += 2
        self.GroupEnd()
        
        # Will push stuff to the left
        self.AddStaticText(ID_DYNMAIC + 1, commonFlag, 1000, 10, "Filler", c4d.BORDER_NONE)
        self.GroupEnd()
        self.GroupEnd()
        return True

def main():
    """
    """
    global myDialog
    myDialog = TabMenuDialog()
    myDialog.Open(c4d.DLG_TYPE_ASYNC)

if __name__ == '__main__':
    main()
This post is deleted!

Hello @AiMiDi,

without any further questions, we will consider this topic as solved by Monday and flag it accordingly.

Thank you for your understanding,
Ferdinand