Comments (7)
Ah, this is my mistake not yours.
The reason you are getting the segfault is that Widget
has no default draw
function. defaultCustomWidgetFuncs
just creates a null pointer because there is nothing else it can do. When the Window
tries to draw
the widget it hits the null pointer and segfaults.
When you use Output
, a widget with a default drawing routine you don't see this.
I think I'm going to change the widget constructor to take a drawing function so the user has to provide one.
What do you think?
Also you're using docs for an unsupported version of FLTK. Here is the version supported by this lib: http://www.fltk.org/doc-1.3/basics.html
from fltkhs.
Ah, I understand now.
I think I'm going to change the widget constructor to take a drawing function so the user has to provide one.
That sounds like a great solution. IMO, if a drawing function is required, the types should reflect that. No null pointers in Haskell! 😄
What drawing function is the FLTK example program using? Does a "default drawing function" exist for widgets? It looks like the default Widget
in FLTK is like a label. That seems kind of weird to me. (Sorry if my terminology is a little off, I'm still learning.)
from fltkhs.
No prob.
The supported example program I linked uses the Fl_Box
widget which has it's own drawing routine.
I've recreated the example from the supported version and I can confirm it works:
module Main where
import qualified Graphics.UI.FLTK.LowLevel.FL as FL
import Graphics.UI.FLTK.LowLevel.Fl_Enumerations
import Graphics.UI.FLTK.LowLevel.FLTKHS
main :: IO ()
main = do
w1 <- windowNew (Size (Width 300) (Height 180)) Nothing (Just "Hello!")
begin w1
let labelRect = Rectangle (Position (X 20) (Y 40)) (Size (Width 260) (Height 100))
label <- boxNew labelRect (Just "Bob") Nothing
setBox label UpBox
setLabelfont label helveticaBoldItalic
setLabelsize label (FontSize 36)
setLabeltype label ShadowLabel
end w1
showWidget w1
_ <- FL.run
return ()
from fltkhs.
For some reason I didn't see your last part about me using the docs from and unsupported version of FLTK. I understand perfectly why my program doesn't work now. I can confirm that your example works. Thanks for your help!
You can close this issue if you want, or leave it open to remind you of the change to Widget
you wanted to make.
from fltkhs.
Uploaded a fixed version to Hackage http://hackage.haskell.org/package/fltkhs.
from fltkhs.
I have made some changes that make working with custom widgets a little easier. This includes some breaking API changes. In your example:
label <- boxNew labelRect (Just "Bob") Nothing
is now:
label <- boxNew labelRect (Just "Bob")
The new version (0.3.0.0) is now up on Hackage. Thanks for bringing this issue to light. It's good to make these changes while the library is still young. :)
from fltkhs.
Yeah, that is a lot cleaner for the probably most common case of non-custom widgets. Thanks!
from fltkhs.
Related Issues (20)
- Return function pointer from `openCallback` so it can be freed. HOT 1
- Crash in FL.eventKey on special key HOT 8
- GL causes c2hs error on Mac due to missing type HOT 4
- after using setIcon on window it doesn't display application HOT 4
- Adding a Scrolled via FLUID generates wrong "scrollNew" call instead of "scrolledNew" HOT 1
- How to enable modern OpenGL? HOT 11
- unable to run basic example under nix HOT 1
- Fltkhs as stack dependency linking error on Windows 10 HOT 1
- install gotchas
- Build error in Setup.hs HOT 2
- Error building bundled fltkhs in custom Setup.hs HOT 1
- fltkhs-fluidtohs generates incorrect module names for nested modules
- addAndGetMenuItem is suprisingly slow HOT 8
- How to call findClicked?
- GHC 8.10.3 linking issue HOT 1
- Syntax error while installing with bundled fltkhs HOT 1
- Build fails with autoconf 2.70 and up HOT 8
- New branch's build artifacts stored in /tmp get erased
- Updating for base-4.14 (ghc 8.10) HOT 2
- cabal-install 3.4.0.0 breaks installation HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fltkhs.