Hi,
You need to construct the Wx::FontpickerCtrl with the minimum arguments
my $ctrl = Wx::FontPickerCtrl->new($someparentwindow, -1);
Passing a font then seems to work OK?
$ctrl->SetSelectedFont(wxNullFont);
.. gets you no font selected
$ctrl->SetSelectedFont (wxSWISS_FONT);
.. gets you an appropriate default font.
If you still have difficulty, what are your versions of Wx, wxWidgets
and operating system?
Regards
Mark
On 15/05/2011 14:01, breno wrote:
Hi everyone!
The code below SegFaults when it tries to $ctrl->SetSelectedFont($font):
----------------------8<----------------------
use strict;
use warnings;
use Wx (':everything');
my $ctrl = Wx::FontPickerCtrl->new();
my $value = '';
my $font = Wx::Font->new(Wx::wxNullFont);
{
local $@;
eval { $font->SetNativeFontInfoUserDesc($value); };
if ($@) {
warn "something's wrong: $@";
$font = Wx::Font->new(Wx::wxNullFont)
}
}
$ctrl->SetSelectedFont($font);
print "yay";
---------------------->8----------------------
I think this might be related to
https://rt.cpan.org/Ticket/Display.html?id=66648 though I'm not sure
how to fix it, since I don't have control over the creation of the
$ctrl variable, only from "my $value = ''" onwards. Assuming this is
not a bug in Wx, what would be the best way to avoid the SegFault?
What I'm thinking is only calling $ctrl->SetSelectedFont($font) if
$value is defined, but shouldn't it work with Wx::wxNullFont ?
Thanks!
breno