"\n" doesn't not work on windows ?  [SOLVED]

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Maeglix
Experienced Solver
Experienced Solver
Posts: 68
Joined: Thu Nov 17, 2016 8:07 am

"\n" doesn't not work on windows ?

Postby Maeglix » Fri Apr 21, 2017 6:01 am

Hey !

I am building a wxTreeCtrl and i would like that some of the item to be on multiple line.
So i use "\n" in the wxString i want to be on multiple line.

It works perfectly on linux but on windows it just ignore the "\n". For example "test\ntest" becomes "testtest".

So did i do something wrong or is this normal ? Is there any workaround ?

Thanks for your help.

PB
wxWorld Domination!
wxWorld Domination!
Posts: 1288
Joined: Sun Jan 03, 2010 5:45 pm

Re: "\n" doesn't not work on windows ?

Postby PB » Fri Apr 21, 2017 6:41 am

Perhaps the native undlerlying control on MSW (tree view) does not support multiline text of its nodes?

Maeglix
Experienced Solver
Experienced Solver
Posts: 68
Joined: Thu Nov 17, 2016 8:07 am

Re: "\n" doesn't not work on windows ?

Postby Maeglix » Fri Apr 21, 2017 6:54 am

I don't know. In this case i would like to know if there is an other way to do what i want.

lfjking
Experienced Solver
Experienced Solver
Posts: 70
Joined: Mon Nov 14, 2016 1:35 pm

Re: "\n" doesn't not work on windows ?

Postby lfjking » Fri Apr 21, 2017 9:57 am

Maeglix wrote:Hey !

I am building a wxTreeCtrl and i would like that some of the item to be on multiple line.
So i use "\n" in the wxString i want to be on multiple line.

It works perfectly on linux but on windows it just ignore the "\n". For example "test\ntest" becomes "testtest".

So did i do something wrong or is this normal ? Is there any workaround ?

Thanks for your help.



You can try to use "\r\n"
"\n" should be valid on the command line

Maeglix
Experienced Solver
Experienced Solver
Posts: 68
Joined: Thu Nov 17, 2016 8:07 am

Re: "\n" doesn't not work on windows ?

Postby Maeglix » Fri Apr 21, 2017 10:58 am

I tried, it didn't work.

Maeglix
Experienced Solver
Experienced Solver
Posts: 68
Joined: Thu Nov 17, 2016 8:07 am

Re: "\n" doesn't not work on windows ?

Postby Maeglix » Mon Apr 24, 2017 5:23 am

Nobody ?

User avatar
doublemax
Moderator
Moderator
Posts: 11387
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: "\n" doesn't not work on windows ?  [SOLVED]

Postby doublemax » Mon Apr 24, 2017 5:40 am

PB wrote:Perhaps the native undlerlying control on MSW (tree view) does not support multiline text of its nodes?
Altough i couldn't find any "official" confirmation on MSDN, i'm pretty sure this is the case. I can't remember to have ever seen a multi-line text in a standard tree control under Windows.
Use the source, Luke!

Maeglix
Experienced Solver
Experienced Solver
Posts: 68
Joined: Thu Nov 17, 2016 8:07 am

Re: "\n" doesn't not work on windows ?

Postby Maeglix » Mon Apr 24, 2017 6:20 am

Ok thank you so i will try to find another way.

New Pagodi
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 203
Joined: Tue Jun 20, 2006 6:47 pm
Contact:

Re: "\n" doesn't not work on windows ?

Postby New Pagodi » Mon Apr 24, 2017 7:26 pm

Maeglix wrote:Ok thank you so i will try to find another way.


Maybe the generic tree control would work. I don't remember how to use it on windows though.

PB
wxWorld Domination!
wxWorld Domination!
Posts: 1288
Joined: Sun Jan 03, 2010 5:45 pm

Re: "\n" doesn't not work on windows ?

Postby PB » Tue Apr 25, 2017 5:36 am

wxGenericTreeCtrl does not properly support multiline node labels either (they overlap).

Code: Select all

#include <wx/wx.h>
#include <wx/treectrl.h>
#include <wx/generic/treectlg.h>

class MyFrame : public wxFrame
{
public:
    MyFrame() : wxFrame(NULL, wxID_ANY, _("Test"))
    {
        wxGenericTreeCtrl* ctrl = new wxGenericTreeCtrl(this, wxID_ANY);
        ctrl->AddRoot("Root\r\nLine2");
        ctrl->AppendItem(ctrl->GetRootItem(), "Item 1\r\nLine2");
        ctrl->AppendItem(ctrl->GetRootItem(), "Item 2\r\nLine2");
        ctrl->ExpandAll();
    }   
};

class MyApp : public wxApp
{
public:   
    bool OnInit()
    {
        (new MyFrame())->Show();
        return true;
    }
}; wxIMPLEMENT_APP(MyApp);


wxDataViewTreeCtrl does not seem to support the feature too but I never used the class so I may have not used it properly

Code: Select all

#include <wx/wx.h>
#include <wx/dataview.h>

class MyFrame : public wxFrame
{
public:
    MyFrame() : wxFrame(NULL, wxID_ANY, _("Test"), wxDefaultPosition, wxSize(200,200))
    {
        wxDataViewTreeCtrl* treeCtrl = new wxDataViewTreeCtrl(this, wxID_ANY);
        wxDataViewItem rootItem = treeCtrl->AppendItem(wxDataViewItem(0), "Root\nLine2");       
    }
};

class MyApp : public wxApp
{
public:   
    bool OnInit()
    {
        (new MyFrame())->Show();
        return true;
    }
}; wxIMPLEMENT_APP(MyApp);


Return to “Platform Related Issues”

Who is online

Users browsing this forum: No registered users and 3 guests