A vertical scroll bar is shown in Single line text control
Posted: Tue Nov 20, 2012 7:25 am
Hi Guys,
I am having a problem while using wxWidgets 2.9.2
I am getting a vertical scroll bar in single line text control for two byte characters on MAC OS.
I have to fix this bug in my project.
So I found the problem which is in wxWidgets-2.9\src\osx\carbon\textctrl.cpp
in this source code we have a function to create a scroll view using which we scroll in text control :
wxMacMLTEHIViewControl::wxMacMLTEHIViewControl( wxTextCtrl *wxPeer,
const wxString& str,
const wxPoint& pos,
const wxSize& size, long style ) : wxMacMLTEControl( wxPeer )
{
m_font = wxPeer->GetFont() ;
m_windowStyle = style ;
Rect bounds = wxMacGetBoundsForControl( wxPeer , pos , size ) ;
wxString st = str ;
wxMacConvertNewlines10To13( &st ) ;
HIRect hr = {
{ bounds.left , bounds.top },
{ bounds.right - bounds.left, bounds.bottom - bounds.top } } ;
m_scrollView = NULL ;
TXNFrameOptions frameOptions = FrameOptionsFromWXStyle( style ) ;
if (( frameOptions & (kTXNWantVScrollBarMask | kTXNWantHScrollBarMask)) || (frameOptions &kTXNSingleLineOnlyMask))
{
if ( frameOptions & (kTXNWantVScrollBarMask | kTXNWantHScrollBarMask) )
{
HIScrollViewCreate(
(frameOptions & kTXNWantHScrollBarMask ? kHIScrollViewOptionsHorizScroll : 0)
| (frameOptions & kTXNWantVScrollBarMask ? kHIScrollViewOptionsVertScroll : 0) ,
&m_scrollView ) ;
}
else
{
HIScrollViewCreate(kHIScrollViewOptionsVertScroll,&m_scrollView);
HIScrollViewSetScrollBarAutoHide(m_scrollView,true);
}
HIViewSetFrame( m_scrollView, &hr );
HIViewSetVisible( m_scrollView, true );
}
m_textView = NULL ;
HITextViewCreate( NULL , 0, frameOptions , &m_textView ) ;
m_txn = HITextViewGetTXNObject( m_textView ) ;
HIViewSetVisible( m_textView , true ) ;
if ( m_scrollView )
{
HIViewAddSubview( m_scrollView , m_textView ) ;
m_controlRef = m_scrollView ;
InstallEventHandler( (WXWidget) m_textView ) ;
}
else
{
HIViewSetFrame( m_textView, &hr );
m_controlRef = m_textView ;
}
AdjustCreationAttributes( *wxWHITE , true ) ;
#ifndef __LP64__
wxMacWindowClipper c( GetWXPeer() ) ;
#endif
SetTXNData( st , kTXNStartOffset, kTXNEndOffset ) ;
TXNSetSelection( m_txn, 0, 0 );
TXNShowSelection( m_txn, kTXNShowStart );
::InstallControlEventHandler( m_textView , GetwxMacTextControlEventHandlerUPP(),
GetEventTypeCount(eventList), eventList, this,
NULL);
}
So as you can see in the else part while creating scroll view we are intentionally creating vertical scroll bar and then hiding it.
Somehow this HIScrollViewSetScrollBarAutoHide function does not seem to be wroking and user can still see vertical scroll bar in single line text control.
For fixing this I tried creating Horizontal bar and then tried to Hide it then Somehow the scroll bar is hidden but there came some other problem in the text control so finally I had to remove those changes and now I need some permanent fix for this issue so that it will not break any other text control functionality.
I have attached the screenshot of the problem. Please have a look.
Please help me for this as this is an important fix for me.
Thanks and Regards,
Vivek
I am having a problem while using wxWidgets 2.9.2
I am getting a vertical scroll bar in single line text control for two byte characters on MAC OS.
I have to fix this bug in my project.
So I found the problem which is in wxWidgets-2.9\src\osx\carbon\textctrl.cpp
in this source code we have a function to create a scroll view using which we scroll in text control :
wxMacMLTEHIViewControl::wxMacMLTEHIViewControl( wxTextCtrl *wxPeer,
const wxString& str,
const wxPoint& pos,
const wxSize& size, long style ) : wxMacMLTEControl( wxPeer )
{
m_font = wxPeer->GetFont() ;
m_windowStyle = style ;
Rect bounds = wxMacGetBoundsForControl( wxPeer , pos , size ) ;
wxString st = str ;
wxMacConvertNewlines10To13( &st ) ;
HIRect hr = {
{ bounds.left , bounds.top },
{ bounds.right - bounds.left, bounds.bottom - bounds.top } } ;
m_scrollView = NULL ;
TXNFrameOptions frameOptions = FrameOptionsFromWXStyle( style ) ;
if (( frameOptions & (kTXNWantVScrollBarMask | kTXNWantHScrollBarMask)) || (frameOptions &kTXNSingleLineOnlyMask))
{
if ( frameOptions & (kTXNWantVScrollBarMask | kTXNWantHScrollBarMask) )
{
HIScrollViewCreate(
(frameOptions & kTXNWantHScrollBarMask ? kHIScrollViewOptionsHorizScroll : 0)
| (frameOptions & kTXNWantVScrollBarMask ? kHIScrollViewOptionsVertScroll : 0) ,
&m_scrollView ) ;
}
else
{
HIScrollViewCreate(kHIScrollViewOptionsVertScroll,&m_scrollView);
HIScrollViewSetScrollBarAutoHide(m_scrollView,true);
}
HIViewSetFrame( m_scrollView, &hr );
HIViewSetVisible( m_scrollView, true );
}
m_textView = NULL ;
HITextViewCreate( NULL , 0, frameOptions , &m_textView ) ;
m_txn = HITextViewGetTXNObject( m_textView ) ;
HIViewSetVisible( m_textView , true ) ;
if ( m_scrollView )
{
HIViewAddSubview( m_scrollView , m_textView ) ;
m_controlRef = m_scrollView ;
InstallEventHandler( (WXWidget) m_textView ) ;
}
else
{
HIViewSetFrame( m_textView, &hr );
m_controlRef = m_textView ;
}
AdjustCreationAttributes( *wxWHITE , true ) ;
#ifndef __LP64__
wxMacWindowClipper c( GetWXPeer() ) ;
#endif
SetTXNData( st , kTXNStartOffset, kTXNEndOffset ) ;
TXNSetSelection( m_txn, 0, 0 );
TXNShowSelection( m_txn, kTXNShowStart );
::InstallControlEventHandler( m_textView , GetwxMacTextControlEventHandlerUPP(),
GetEventTypeCount(eventList), eventList, this,
NULL);
}
So as you can see in the else part while creating scroll view we are intentionally creating vertical scroll bar and then hiding it.
Somehow this HIScrollViewSetScrollBarAutoHide function does not seem to be wroking and user can still see vertical scroll bar in single line text control.
For fixing this I tried creating Horizontal bar and then tried to Hide it then Somehow the scroll bar is hidden but there came some other problem in the text control so finally I had to remove those changes and now I need some permanent fix for this issue so that it will not break any other text control functionality.
I have attached the screenshot of the problem. Please have a look.
Please help me for this as this is an important fix for me.
Thanks and Regards,
Vivek