1.4k views
in GUI Development by
Hello,

In my GUI I've a mesage box component to display a message as a modal window with a button to exit and remove it from the screen.
I noticed by default it's possible to move the window over the screen.

How can I keep it at a fixed position on the screen?

Kind regards,

Robert

1 Answer

0 votes
by
 
Best answer

Hi Robert,

by default every component has the position that is set to the Bounds property. It is already a fixed position.

Of course, you can implement some logic so that you can move a component during runtime - but by default it is fixed.

Hope this answers your question....

Best regards,

Manfred.

by

Hi Manfred,

Thanks for your answer but that's what I've done already and my question was too brief.

The slot onShowMessageBox implements:

// Obtain access to the root object.
var Core::Root rootObject = GetRoot();

// Create a new instance of a message box component.
var Example::MessageBox messageBox = new Example::MessageBox;

// Initialize it (e.g. define position on the screen, 
// or content of the message box, etc.)
messageBox.Bounds.origin = <25,280>;
messageBox.Caption = "Test";
messageBox.Message = "This is a test of a message box with a long long line of text";
messageBox.Visible = true;

// Eventually connect the message box with a slot method to execute
// when the user has confirmed the message, etc. Within this method
// the message box will end the modal state and disappear.
messageBox.OnExit = onHideMessageBox;

// Add the message box component directly to the application component.
// Thereupon the message box will appear.
rootObject.Add( messageBox, 0 );
// And route keyboard events to it
rootObject.Focus = messageBox;

// ... and finally make the message box component modal, so no other
// component receives user inputs as long as the message box is modal.
rootObject.BeginModal( messageBox );

Now if I run the application it shows the message box but if I use the touch screen I'm able to slide and moe it to a different position on the screen.

That's not what I want, I want it to be fixed at the specified position. Basically the user should not be able to move the positon of my modal message box (the user is only allowed to press the Ok button to exit the modal message box).

What is the best way to achieve this?

Kind regards,

Robert

by

Thanks for the additional infos.

Well, every component behaves as it is implemented. There is nothing automatic or hidden or mystic... This means, if your message box reacts on a certain move gesture, then it is because the message box or one of its super classes contains the necessary implementation for doing that.

Please have a look into your class Example::MessageBox - there you should find some touch handler (e.g. SimpleTouchHandler) that is connected to a slot method which adjusts the Bounds of the message box according to the position of the touch handler, right?

You can delete the touch handler and the slot method if not needed...

 

by
Looking further, I see indeed the MessageBox (which is a derived Paste of your Example::MessagePanel) has a Panel that has an onDrag slot method. So in this specific instance I can set the onDrag handler to null?
by
Yes if you have derived the panel you can set OnDrag to null to "cut" the connection between the touch handler and the slot method.

But maybe it makes sense to implement (copy) your own message panel class instead of deriving it from some sample code.
by
Yes, this now works indeed!

Thank you for pointing me in the right direction. When our GUI design has finished, I'll make my own set of panel(s) but for now I'm just figuring out what Embedded Wizard is able to do for me and how it all works.

Kind regards,

Robert

Embedded Wizard Website | Privacy Policy | Imprint

...