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

TextView / Scroll Example doesn't work #87

Closed
Scimon opened this issue Dec 18, 2018 · 6 comments
Closed

TextView / Scroll Example doesn't work #87

Scimon opened this issue Dec 18, 2018 · 6 comments

Comments

@Scimon
Copy link

Scimon commented Dec 18, 2018

The TextView in an ScrolledWindow exmaple fails. It would appear that TestViews can't be editted within the code giving an error of "Cannot modify an immutable Str ()"

@jonathanstowe
Copy link
Contributor

I think you're going to have to talk us through this as I can't get the as-is examples/17-scrolled-window-with-textview.p6 to do anything untoward.

@Scimon
Copy link
Author

Scimon commented Dec 18, 2018

Sorry, was mostly working through my Advent calender article at the time (suprise guess what it's about?).
I'll investigate further.

@Scimon
Copy link
Author

Scimon commented Dec 18, 2018

Ok. Using GTK::Simple:ver<0.1.10> (from zef). I ran the following code :

#!/usr/bin/env perl6

use v6;
use GTK::Simple;
use GTK::Simple::App;

my $app = GTK::Simple::App.new(title=> 'Test');
my $text = GTK::Simple::TextView.new(text=>'Original');
my $button = GTK::Simple::ToggleButton.new(label=>'Update');

$button.clicked.tap( { $text.text = "New" } );

$app.set-content(
    GTK::Simple::VBox.new( 
	$text,
	$button,
    )
);
$app.border-width = 20;
$app.run;

The App opens but the Text box is empty and when I click the update I get the following :

Cannot modify an immutable Str ()
  in block <unit> at src/perl6/desktop-apps/text-test.p6 line 11

Perl6 version 2018.11 built on MoarVM version 2018.11

@Xliff
Copy link

Xliff commented Dec 19, 2018

This is due to the fact that the accessor method:

method text() {
    Proxy.new:
        FETCH => {
            gtk_text_buffer_get_text($!buffer, self!start-iter(),
                self!end-iter(), 1)
        },
        STORE => -> \c, \text {
            gtk_text_buffer_set_text($!buffer, text.Str, -1);
        }
}

Is not "is rw". I think this code worked up until a recent commit of Perl6, where the bug that allowed this to work without the 'rw' trait was fixed.

@jonathanstowe
Copy link
Contributor

Yeah that's entirely what it is.

Let me have a quick look at that.

@jonathanstowe
Copy link
Contributor

As it stands the constructor for the TextView doesn't do anything with a text argument. Arguably it should but that should probably be handled separately as it will require a bit of a rework of the whole class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants