Jump to content
Sign in to follow this  
DZR_Mikhail

How to make draggable image in a dialog with limited moving borders.

Recommended Posts

I need to make some object\image manual dragging manipulations. This method is needed for my IAS - Interactive Actions System

For example you have a rifle bolt part image with draggable bolt stick.

You drag it down to insert a bullet in a barrel.

Look at the schematic video.

hcOS8Kt0-U4

What is the technology for doing it in a dialog? I just fail to find the main concept, main methods to do it. I can't even make my picture move by a script command ctrlSetPosition.

Any examples or some link to demo or addon using it will be much apprecieated.

Thanks in advance.

P.s. Ace gestures are usless. It is not working with images.

Edited by zvukoper

Share this post


Link to post
Share on other sites

You need to have your dialog with

movingEnable = true;

and your image control with

moving = true;

Not sure how to restrict movement though.

Share this post


Link to post
Share on other sites

Oh, just a note, this will probably move entire dialog, not just image control. I'm not sure if moving only one control with mouse is possible.

As for ctrlSetPos, don't forget to commit your control changes with ctrlCommit

Share this post


Link to post
Share on other sites

As sumatra said above. As to your other tasks... I would recomend using a uiEventHandler to capture the drag, then send that screen position to a function and then you can check the pos to see if its out of bounds or if you need to activate something else. You should also be able to set the ctrl pos with this func as well.

Share this post


Link to post
Share on other sites
Oh, just a note, this will probably move entire dialog, not just image control. I'm not sure if moving only one control with mouse is possible.

As for ctrlSetPos, don't forget to commit your control changes with ctrlCommit

SuMatra, thank you so much. Commit was the only thing I couldn't get. Now it works.

Here's the full code I used and which worked for all who will stumble upon this problem

(findDisplay 88) displayAddEventHandler  ["mouseButtonDown", 'hint "DOWN"; _display = findDisplay 88; _control = _display displayCtrl 4; _control ctrlSetPosition [0.7, 0.7]; _control ctrlCommit 2;'];

Share this post


Link to post
Share on other sites

The mouse down event also passes the pos of the mouse. You can set the pos of the _control to that pos. It will look like your moving it with the mouse.

I also re-coded your EH to make it more readable and fixed a small error.

myfnc = {
hint "DOWN";
_display = findDisplay 88;
_control = _display displayCtrl 4;
_control ctrlSetPosition [color=#ff0000](_this select 2)[/color];
_control ctrlCommit 2;
};


(findDisplay 88) displayAddEventHandler  ["mouseButtonDown", "_this call myfnc"];

Just take a look at what the mouseButtonDown EH returns here you can use that in this way and others.

Share this post


Link to post
Share on other sites

You can also create dialogs inside another dialog.

class container {
  class child_1 {

  }
  class child_2 {

  }
}

That way (I belive) you will have the child_1 and child_2 inside container, and they should not get out of bounds of it.

Edited by neokika

Share this post


Link to post
Share on other sites

Thanks neokikka. I'll try this nesting. Seems logical and obvious and I hope it works.

Share this post


Link to post
Share on other sites

Not worked.

Here's the code.

The two child classes work well separately, but nothing happens when nested as you desrcribe.

class ak107container
{
name = ak107container;
idd = 92;
movingEnable = false;
enableSimulation = true;
controlsBackground[] = { };    // no background controls needed
objects[] = { };               // no objects needed
controls[] = {ak107magd, ak107d};

class ak107magd 
{
name = ak107magd;
idd = 91;
movingEnable = false;
enableSimulation = true;
controlsBackground[] = { };    // no background controls needed
objects[] = { };               // no objects needed
controls[] = {ak107mag};
	class ak107mag {

		idc = 0;
			type = CT_STATIC;
			style = ST_PICTURE;
			text = "ias\m_ak107_ca.paa";
			sizeEx = 0.2;
			moving = true;
			font = FontM;
			colorBackground[] = { 1, 1, 1, 0.3 };
			colorText[] = { 1, 1, 1, 1 };
			x = 0.2;
			y = 0.2;
			w = 0.3;
			h = 0.3;

		};


};

class ak107d 
{
name = ak107d;
idd = 90;
movingEnable = false;
enableSimulation = true;
controlsBackground[] = { };    // no background controls needed
objects[] = { };               // no objects needed
controls[] = {ak107nomag};
	class ak107nomag {

		idc = 0;
model = "\ca\ui\compass.p3d";
direction[] = {0,0.500000,0.500000 };
up[] = {0,1,0 };
positionBack[] = {0,-0.020000,0.075000 };
scale = 0.440000;
text = "ias\w_ak107_kobra_ca_nomag.paa";
		};
};
};

I understood I need the same functions as Arma2 has when the map is displayed with draggable compass, radio and watch... So it's technically possible. If only somebody could point me to a pbo where to llok for it?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×