how do you atttach 3 objects attached to each other?

Jun 2, 2018 at 12:53pm
yeah it looks pretty cool, but I haven't the foggiest idea
how its done...

1
2
3
4
5
6
7
 	else
	{
		if( wnd.kbd.KeyIsPressed( VK_RETURN ) )
		{
			isStarted = true;
		}
	}
Jun 2, 2018 at 1:59pm
What do you mean by "attach"?

What are the types of 'wnd', 'kbd', and 'KeyPressed'?
Jun 2, 2018 at 2:40pm
looks like windows gui code, those would be library entities if so, not something he made.

this says "if the enter key is pressed, set Boolean isstarted to true" which probably activates something in another thread or event handler, the bool is likely some nearly-global member of the gui class framework, at a guess... so a class member but on a scale so big it may as well be global... but I am guessing a lot from a little here !!!

no clue what attach means here.
Last edited on Jun 2, 2018 at 2:41pm
Jun 3, 2018 at 12:15am
the only info I can give is that all of them are in separate header files as I don't understand whats going on and the code is too big to put on the boards, attach is probably not the word
but what I meant to ask is is it possible to put three objects together (like above) coz usually I only see only one dot operator and not two
Jun 3, 2018 at 12:57am
programmy, both jonnin and keskiverto said that they didn't know what you meant when you said attach objects to each other, but then you pretty much repeat yourself (attach -> put, each other -> together) in your explanation.

Do you mean you want to know when a user pressed three buttons at once, like Ctrl+Shift+Return?

I do not have your framework, but maybe something like this?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// how to respond to key press event

// keep processing events as long as queue contains them
while( !wnd.kbd.KeyIsEmpty() )
{
	// get an event from the queue
	const Keyboard::Event e = wnd.kbd.ReadKey();
	
	// check if it is a press event
	if( e.IsPress() )
	{
		// check if the event was for the return key
		if( e.GetCode() == VK_RETURN )
		{
			// respond to CTRL + SHIFT + RETURN key press event
			if( wnd.kbd.KeyIsPressed(VK_CONTROL) 
			 && wnd.kbd.KeyIsPressed(VK_SHIFT) )
			{
				// handle event or boolean or whatever
				isStarted = true;
			}
		}
	}
}


TBH I would use a game framework like SFML over whatever you're using (Chili Framework?)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <SFML/Graphics.hpp>
#include <iostream>

int main()
{
    sf::RenderWindow window({1000, 600}, "Test");
    window.setVerticalSyncEnabled(true);

    while(window.isOpen())
        {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
            {
                return 0;
            }
                        else if(event.type == sf::Event::KeyPressed)
                        {
                                std::cout << event.key.code << " a: " << (int) event.key.alt << " c: " << (int) event.key.control << " s: " << (int) event.key.shift << "\n";
                        }
        }

        window.clear();
        window.display();
    }
}
Jun 3, 2018 at 3:23am
yes this is the chili framework, I've seen SFML and it looks promising, will try it
Last edited on Jun 3, 2018 at 8:31am
Jun 3, 2018 at 9:25am
The member access operator?
1
2
3
4
5
6
7
8
9
10
11
#include <string>
#include <iostream>

struct Foo {
  std::string kbd;
};

int main() {
  Foo wnd;
  std::cout << wnd.kbd.size() << '\n';
}

Here, like in your code, the object 'wnd' is of type that has publicly accessible data member 'kbd'.
The 'kbd' is in turn of type that has public member functions (like KeyIsPressed() or size() ).

The member-of operator has left to right evaluation order (like iostream's <<), i.e.
1
2
3
wnd.kbd.KeyIsPressed( VK_RETURN )
// is same as
(wnd.kbd).KeyIsPressed( VK_RETURN )
Topic archived. No new replies allowed.