Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Max length on multiple line text control for GTK #23928

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

oneeyeman1
Copy link
Contributor

The text control on Windows supports this, so this PR will bring it in par.

This PR resolves issue 17772.

Only 2 last commits are relevant. Sorry - I thought I was updating master.

Vadim didn't have time back then to finish it. Hopefully he will now. Or Paul.

Hopefully either he or Paul will be able to comment.

What doesn't work here is pasting in the multi-line text control.

I look at implementation, but I'm not sure how to best implement that.

Please review.

I can try to take a look at pasting, but it will take some time..

Thank you.

Copy link
Contributor

@vadz vadz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, there are still several problematic parts here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and all the other submodules shouldn't be changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vadz ,
They shouldn't.
As explained in the OP, I thought I was pushing the to master.

@@ -62,7 +62,7 @@ class WXDLLIMPEXP_CORE wxTextEntry : public wxTextEntryBase
void SendMaxLenEvent();
bool GTKEntryOnInsertText(const char* text);
bool GTKIsUpperCase() const { return m_isUpperCase; }

int GetMaxLength() const { return m_maxlen; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's GTK-specific, it should have GTK prefix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vadz,
I probably won't.
I plan to update Mac port with this..

@@ -99,7 +99,7 @@ class WXDLLIMPEXP_CORE wxTextEntry : public wxTextEntryBase
// Call this from the overridden wxWindow::GTKIMFilterKeypress() to use
// GtkEntry IM context.
int GTKEntryIMFilterKeypress(GdkEventKey* event) const;

int m_maxlen;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be defined below, with the other member variables and initialized in its declaration as all new fields should be in master.

// the handler that does not connected after
gtk_text_buffer_delete( buffer, &offset, &end );
// Without following line GTK3 produces warning
#if GTK_CHECK_VERSION( 3, 0, 0 )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is useless, all this code seems to be GTK 3-specific.

wxCommandEvent event( wxEVT_TEXT_MAXLEN, win->GetId() );
event.SetEventObject( win );
event.SetString( win->GetValue() );
win->HandleWindowEvent( event );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems very suspicious that the result is not being used. Normally it is possible to increase the max length when this event happens.

// reason, ("Run Last") it won't work in GTKOnInsertText() as it called from
// the handler that does not connected after
gtk_text_buffer_delete( buffer, &offset, &end );
// Without following line GTK3 produces warning
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which warning?

// probably because the signal is documented as "Run Last". For exactly same
// reason, ("Run Last") it won't work in GTKOnInsertText() as it called from
// the handler that does not connected after
gtk_text_buffer_delete( buffer, &offset, &end );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we should delete just enough to stay under maxlen and not all new entry.

Comment on lines +945 to +948
if( IsSingleLine() )
return GTK_EDITABLE(m_text);
else
return nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this necessary? We still shouldn't be calling this for multiline controls, it doesn't make sense as they don't have any GtkEditable.

It looks like this is a leftover and should be simply reverted.

Comment on lines 917 to +920
GtkEntry* const entry = (GtkEntry*)GetEditable();
if (!GTK_IS_ENTRY(entry))
return;

gtk_entry_set_max_length(entry, len);
m_maxlen = len;
if (entry)
gtk_entry_set_max_length(entry, len);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be reverted too.

@vadz vadz added work needed Too useful to close, but can't be applied in current state GTK labels Oct 2, 2023
@oneeyeman1
Copy link
Contributor Author

@vadz ,
Is there a reason those builds are marked failed even though they are completed without any errors up to wxrc binary?

Thank you.

@swt2c
Copy link
Contributor

swt2c commented Oct 5, 2023

@vadz , Is there a reason those builds are marked failed even though they are completed without any errors up to wxrc binary?

Thank you.

The errors happened much earlier. Search the logs for "error:".

@oneeyeman1
Copy link
Contributor Author

@swt2c

The errors happened much earlier. Search the logs for "error:".,

Thx. I presume they are here because I pushed the Scintilla update.
However they are unrelated.

Is it possible to fix them somehow? I'm not that proficient with Git...

@swt2c
Copy link
Contributor

swt2c commented Oct 5, 2023

@swt2c

The errors happened much earlier. Search the logs for "error:".,

Thx. I presume they are here because I pushed the Scintilla update. However they are unrelated.

Is it possible to fix them somehow? I'm not that proficient with Git...

It sure looks like they are related to Scintilla.

Yes, it is possible to fix them, but it might be easier for you to create a fresh clone of master and manually re-apply your changes there.

@oneeyeman1
Copy link
Contributor Author

@swt2c ,

@swt2c

The errors happened much earlier. Search the logs for "error:".,

Thx. I presume they are here because I pushed the Scintilla update. However they are unrelated.
Is it possible to fix them somehow? I'm not that proficient with Git...

It sure looks like they are related to Scintilla.

Yes, it is possible to fix them, but it might be easier for you to create a fresh clone of master and manually re-apply your changes there.

Well re-clone will probably be too harsh. ;-)
However I might just sync the master with my fork online, fetch/pull into master and recreate the branch.

This will probably work the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GTK work needed Too useful to close, but can't be applied in current state
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants