The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 GETN Apply button
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

couturier

France
291 Posts

Posted - 12/14/2017 :  2:49:26 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 2018
Operating System: win10

Hi,

in a GETN box with Apply button, that button becomes inactive after 1st click and won't be active unless a change is made in the dialog.

Is it possible to have that Apply button always active ?

Thanks

yuki_wu

896 Posts

Posted - 12/15/2017 :  01:01:23 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

I am sorry that we cannot keep the Apply button always active now.

I think it is easy to understand why the Apply button becomes inactive until you make some changes in GetN dialog. I mean the user will be easy to know if he has clicked the Apply button or not in such mechanism. I am wondering why you hope to keep it always active which may confuse the user sometimes. Could you please tell me your case?

Regards,
Yuki
OriginLab
Go to Top of Page

couturier

France
291 Posts

Posted - 12/15/2017 :  03:35:54 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I fully understand that apply button needs to get inactive once clicked.
I have a particular case where I may want to repeatedly apply a computation on a dataset. So I was wondering if there was an option to keep that button activated.
Go to Top of Page

yuki_wu

896 Posts

Posted - 12/17/2017 :  10:04:11 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Just like I mentioned before, Origin cannot keep the Apply button always active so far, but we have added this issue to our improvement tracking database: ID: ORG-17523. We may add a system variable to control it.

For now, we could replace the Apply button with a normal button. For example, the Multiple button and the Divide button in this example:

#include <origin.h>
#include <GetNbox.h>
#include <xfutils.h>
static bool _action_event(TreeNode& trGUI, int nRow, int nCol, TreeNode& trNode, DWORD dwCntrl, int nType, WndContainer& theDlg)
{
	if (GETNEVENT_ON_INIT == dwCntrl)
		return true;
	
	DataRange dr;
	TreeNode trIX = trGUI.ix;
        int nFactor = trGUI.factor.nVal;
	okxf_resolve_tree_construct_range(&trIX, &dr);
	if (dr && dr.GetNumRanges() > 0)
	{
		Column col;
		range_get_col(dr, 0, col);
		if (col)
		{
			vectorbase& vv = col.GetDataObject();
			if (trNode.nVal == 0)
				vv = vv * nFactor;
			else
				vv /= nFactor;
		}
	}
	
    return true;
}
void GETN_BUTTON_ex()
{
    GETN_BOX( treeTest )
    GETN_INTERACTIVE(ix, "Input", "")
    GETN_NUM(factor, "Factor", 10)
    GETN_BUTTON_GROUP(action, "", 2, "Multiple|Divide")  GETN_OPTION_EVENT_EX(_action_event)
    GETN_CURRENT_SUBNODE.SetAttribute(STR_INTERACTIVE_CONTROL_OPTIONS_ATTRIB, 0x00400010);
    GETN_OPTION_DISPLAY_FORMAT(DISPLAY_EDITOR_HORZ|DISPLAY_EDITOR_RIGHT)
    
    if( GetNBox( treeTest, "Calculate", "" ))
        out_tree( treeTest );
}

Hope it helps.

Regards,
Yuki
OriginLab

Edited by - yuki_wu on 12/18/2017 12:43:56 AM
Go to Top of Page

couturier

France
291 Posts

Posted - 12/18/2017 :  07:00:34 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you so much. Didn't know it was possible to add custom buttons.

This is exactly what I was looking for
Go to Top of Page

couturier

France
291 Posts

Posted - 12/18/2017 :  3:17:28 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I have an additional question.

say I want to record the overall operation and output it IF users clicks Cancel:

static bool _action_event(TreeNode& trGUI, int nRow, int nCol, TreeNode& trNode, DWORD dwCntrl, int nType, WndContainer& theDlg)
{
	if (GETNEVENT_ON_INIT == dwCntrl)
		return true;
	
	DataRange dr;
	TreeNode trIX = trGUI.ix;
        int nFactor = trGUI.factor.nVal;
	okxf_resolve_tree_construct_range(&trIX, &dr);
	if (dr && dr.GetNumRanges() > 0)
	{
		Column col;
		range_get_col(dr, 0, col);
		if (col)
		{
			vectorbase& vv = col.GetDataObject();
			if (trNode.nVal == 0)
			{
				vv = vv * nFactor;
				trGUI.Total.dVal*=10;
			}
			else
			{
				vv /= nFactor;
				trGUI.Total.dVal/=10;
			}
		}
	}
	
    return true;
}
void GETN_BUTTON_ex()
{
    GETN_BOX( treeTest )
    GETN_INTERACTIVE(ix, "Input", "")
    GETN_NUM(factor, "Factor", 10)
    GETN_NUM(Total, "Total", 1)
    GETN_BUTTON_GROUP(action, "", 2, "Multiple|Divide")  GETN_OPTION_EVENT_EX(_action_event)
    GETN_CURRENT_SUBNODE.SetAttribute(STR_INTERACTIVE_CONTROL_OPTIONS_ATTRIB, 0x00400010);
    GETN_OPTION_DISPLAY_FORMAT(DISPLAY_EDITOR_HORZ|DISPLAY_EDITOR_RIGHT)
    
    if( GetNBox( treeTest, "Calculate", "" ))
        out_tree( treeTest );
    else out_double("total=", treeTest.Total.dVal);
}


treeTest.Total.dVal always outputs 1, even if it is correctly displayed in dialog.
How can I output what I see in the dialog ?
Go to Top of Page

couturier

France
291 Posts

Posted - 12/18/2017 :  4:51:53 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
And a bonus question:
How to display a symbol (like that rightward triangle in save theme Xf) in a button ?

Thanks for the help
Go to Top of Page

yuki_wu

896 Posts

Posted - 12/18/2017 :  10:24:27 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

It seems that the GetN GUI tree will be only updated when OK button is clicked at present. I am not sure if this is by design or a bug. I also put this issue into ID: ORG-17523, our developer will help to do further check later.

We cannot add a symbol to the button of a GetN box. If you want to make an App with the attractive GUI, I will suggest you try the new feature: Origin C HTML Dialog with JavaScript Support:
https://www.originlab.com/doc/OriginC/guide/HTML-Dialog

Regards,
Yuki
OriginLab

Go to Top of Page

couturier

France
291 Posts

Posted - 12/19/2017 :  03:16:39 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I want my code to be compatible with O2016 so html dialog is not an option.

As for the GETN_BUTTON_GROUP buttons, it is possible to justify left or right with GETN_OPTION_DISPLAY_FORMAT.
Is it possible to center the buttons ?
Go to Top of Page

yuki_wu

896 Posts

Posted - 12/20/2017 :  12:53:43 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Yes, we can set the alignment by GETN_OPTION_DISPLAY_FORMAT, for example:

GETN_BUTTON_GROUP(Button, "", 2, "Open...|Save...")
    	GETN_OPTION_DISPLAY_FORMAT(DISPLAY_EDITOR_LEFT)
	// GETN_OPTION_DISPLAY_FORMAT(DISPLAY_EDITOR_RIGHT)

However, the right-aligned button may not at the position you want to put:


Regards,
Yuki
OriginLab
Go to Top of Page

couturier

France
291 Posts

Posted - 12/20/2017 :  06:02:23 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks for your help.

Another thing:
Once user clicks the Apply button, the Cancel button becomes a Close button.
Is there any option so that the Cancel button keeps showing Cancel ?

thanks
Go to Top of Page

yuki_wu

896 Posts

Posted - 12/21/2017 :  04:36:24 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

I am sorry that it is also by design and there is no such option so far. I suppose we may hope the user to know that he cannot cancel the operation to reverse the last change and only click the Close button to close the dialog after he clicks the Apply button.

However, I would like to know why you want to keep showing Cancel if you don’t mind sharing your idea.

Regards,
Yuki
OriginLab
Go to Top of Page

couturier

France
291 Posts

Posted - 12/21/2017 :  4:10:57 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I wanted to apply from within the dialog some operations that change the input data. User could see the effect of different options with apply, and could revert back to original data with cancel.

Don't mind with that, I could workaround it with the use of GETN_BUTTON_GROUP

thanks
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000