Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6628213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:06:16+00:00 2026-05-25T22:06:16+00:00

I want draw on the background (like a rectangle or such) and then have

  • 0

I want draw on the background (like a rectangle or such) and then have it render the components on top of that. The components would be on top of what I drew. Is there a way to do this?

Here’s an example of the concept. This only displays the rectangle. So… just need some way to tell it to go render the components, too.

{-# LANGUAGE PackageImports #-}

import Graphics.UI.Gtk
import Graphics.UI.Gtk.Gdk.EventM
import Graphics.UI.Gtk.Gdk.GC
import "mtl" Control.Monad.Trans(liftIO)

main = do
  initGUI
  window <- windowNew
  window `onDestroy` mainQuit
  windowSetDefaultSize window 800 600
  windowSetPosition window WinPosCenter

  table <- tableNew 3 3 False
  button <- buttonNewWithLabel "Test Button"
  tableAttachDefaults table button 1 2 1 2
  containerAdd window table
  table `on` exposeEvent $ update
  widgetShowAll table

  widgetShowAll window
  mainGUI

update = do
  win <- eventWindow
  liftIO $ do
    gc <- gcNew win
    drawRectangle win gc False 10 10 90 90
  return True
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T22:06:17+00:00Added an answer on May 25, 2026 at 10:06 pm

    This is not particular to gtk2hs. According to http://developer.gnome.org/gtk/2.24/GtkWidget.html#GtkWidget-expose-event you need to return False in your update handler, so that other handlers are also called afterwards.

    When you change this in your example, the button will cover the whole window, so the rectangle is hidden. But, for example, with tableSetHomogeneous table True you get the desired effect.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to draw some listview items disabled and would like to mimic the
I have 3d mesh and I would like to draw each face a 2d
Background : I would like to draw blocks when the user touch up somewhere.
I want to draw this in my view to draw this line, I have
I want to draw a graph in my Django-based site, to look like these
I want to draw a line in Crystal report. I can do that from
I have an image with 595x842px dimensions, I would like to use the image
I would like to use an image for background in the canvas element provided
Think that I have many activities,and all I want is this: I have a
Let's say I want to draw a simple quad like this: glBegin(GL_QUADS); glVertex2f(-1.0,-1.0); glVertex2f(1.0,-1.0);

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.