Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - anttirt

Pages: [1]
1
System / No MouseButtonPressed/Released events with QSFMLCanvas
« on: April 18, 2011, 09:16:02 am »
Alright. I mucked about a bit and found out that I can get the missing events by adding these virtual function overrides to my canvas class:

Code: [Select]

void mousePressEvent(QMouseEvent* event) {
    std::cout << "mouse down" << std::endl;
}
void mouseReleaseEvent(QMouseEvent* event) {
    std::cout << "mouse up" << std::endl;
}


Is there any sensible way I could modify QSFMLCanvas to catch these and add them into the SFML event queue? I notice that the event queue is managed by the sf::priv::WindowImpl class which is opaque to clients of the library, so it would appear that I'd have to modify the library itself for this, but maybe I'm missing something.

2
System / No MouseButtonPressed/Released events with QSFMLCanvas
« on: April 18, 2011, 08:43:51 am »
Yes.

3
System / No MouseButtonPressed/Released events with QSFMLCanvas
« on: April 18, 2011, 08:02:22 am »
Hi, I'm using SFML2 (git commit 71469f18153d8a86611310684cdfdee380ad2495) and I'm having some problems with input.

I managed to draw in a Qt widget using the code from the QSFMLCanvas tutorial for 1.6 (.hpp, .cpp) and it works fine, except that I'm not getting MouseButtonPressed/Released events with PollEvent. I am however getting all sorts of other events, like MouseMoved/Entered/Left and KeyPressed/Released. I'm guessing that for some reason Qt swallows the mouse button events, but I have no idea where to start looking for the cause.

Here's my code (with my own irrelevant bits commented out):

Code: [Select]

#include "graphics/QSFMLCanvas.hpp"
// #include "graphics/Board.hpp"

#include <Qt/qapplication.h>
#include <Qt/qframe.h>
// #include <memory>
#include <iostream>

struct HayagoCanvas : QSFMLCanvas {
    HayagoCanvas(QWidget* parent, const QPoint& pos, const QSize& size, int gridSize)
        : QSFMLCanvas(parent, pos, size)
        , gridSize(gridSize)
        // , board(NULL)
    {
    }

private:
    int gridSize;
    // std::unique_ptr<Board> board;

    void OnInit() {
        // board.reset(new Board(GetWidth(), GameState(gridSize)));
    }

    void OnUpdate() {
        sf::Event event;
        while(PollEvent(event)) {
            std::cout << "Event polled: " << event.Type << std::endl;
            // if(event.Type == sf::Event::MouseButtonReleased) {
            //     board->place(ConvertCoords(GetInput().GetMouseX(), GetInput().GetMouseY()));
            // }
        }
        // board->drawBoard(*this);
        // board->drawStones(*this);
    }
};

int main(int argc, char** argv) {
    QApplication app(argc, argv);
    QFrame* frame = new QFrame;
    frame->setWindowTitle("Hayago");
    frame->resize(640, 640);
    frame->show();

    HayagoCanvas* canvas = new HayagoCanvas(frame, QPoint(20, 20), QSize(600, 600), 9);
    canvas->show();

    return app.exec();
}

Pages: [1]
anything