Button text change from another activity - button

I'm having problem in changing the text of a button in main activity. I want to change the text of that button upon click on another button which is in second activity. Please help me with the solution?

There are many ways to do it but simplest way to do it is- You can maintain a static boolean variable in any of your activity and change its value to true on the button click of your other activity and whenever your AainActivity resumes you can check in its onResume() method for this variable and if it is true -> change the text of your button in MainActivity.

Related

Genexus - Disable Text Block used as button

I have a Text Block that I use as a button (with enter event) and when I press it it takes a while to do what it has to do, so you can click more than once the button and it does it twice or more times. So what I want to do is to disable or to hide the text block while its doing its job, but the text block only hides when it exits the enter event, which is to late because I already could pressed several times the buttom.
How can I find a solution for this? Is there a way to disable or hide the text block when I enter the enter event but before it exit the event?
I suppose you are calling a procedure. Try to use
MyProcedure.Submit()
instead of
MyProcedure.Call()

No event getting generated on button click in MFC

I have a dialog based application. I have one static text control and a button on this, both of which I have made invisible in the beginning. I want to show both the controls on reaching a certain condition. When I click this button, again I want to make both the controls invisible.
However, I am able to show and hide the control and also captured the button click event like this:
ON_BN_CLICKED(IDC_MY_BUTTON, &MyDlg::OnBnClickedMyButton)
and defined OnBnClickedMyButton().
But when I press the button, it is not pressed and the event is also not generated.
Any suggestions?
First check if the IDC_MY_BUTTON exists and is valid.
Remember to add DECLARE_MESSAGE_MAP() at the header file.
Also check at the BEGIN_MESSAGE_MAP(MyClass,MyParentClass) if the class
and the parent class you write are right.
I hope this helps.
I think the IDC_MY_BUTTON maybe is invalid or other control has the same ID.
Well, finally I have come to know that though the button was visible but on clicking it was not taking control, hence I used BringWindowToTop() to draw it on top. Now it is being clicked and OnBnClickedMyButton() is also being called.
But now the issue is that after calling BringWindowToTop() the button is not shown. It is shown only when I take the mouse pointer on it. Not able to understand what is the issue.

How to set the old value which was selected earlier, after a value change event fired

I am facing a problem like I have one Vaadin ComboBox with preselected value.I am changing the value from the ComboBox to another value,then ValueChangeEvent is fired.Inside the valueChange method I have written something to show a Popup Window which has Cancel and Ok button.Upon clicking on OK button of Popup Window I am going with the changed value of the ComboBox but upon clicking on Cancel button I just want to have the old value which was there before value change event fired.
Could anyone please help me out from the above issue?
Thanks in advance.
Maybe you can save whatever SelectedItem the combobox has when the event is fired, and if the user pressed cancel, you reset it to this stored item.
Before the click, how do you know what is selected in the click? Of course, you need to store the current selection somewhere. Lets call it currentSelectedValue (it could be NULL in the begining)
On click, you have a new selection, lets call it newSelectedValue
Now, if you do not want to go with this newSelectedValue, simply do this:
combo.setValue(currentSelectedValue);

QTableView: Best way to change activation-trigger to double-click

In my application, I have one tableview of items, and a side-panel "preview":ing the latest selected item.
I want clicking on an item to change the selection, and double-clicking to cause a "run"-action to be performed. More specifically, I want the "run"-action (including key-navigation and pressing enter) to be bound to the "activation" of the item in the table-row.
My problem is; single-clicks does not only change the selection, but fires the "activated" signal on the item. I would like to tweak it such that:
Navigation Keys, Single Mouse Click: Selection-change, update preview-panel
Enter Key, Double Mouse Click: Activate/run/open action triggered.
Is there a nice clean way to do it, or are overriding the onclick/doubleclick events my best option? Or is there some other tabular list-widget better suiting my needs?
I would connect the slot for the preview action to the currentChanged() signal of the table view's selectionModel(). This covers single clicks and key navigation.
Then there's two options for the double clicks and Enter key presses:
Subclass your tableview, override doubleClickEvent() and keyPressEvent() and fire your custom signal in there, with maybe the model index or something else as an argument. Then just connect your run method to your own signal as you have full control over when it is fired.
If you don't want to subclass, you can use the installEventFilter() mechanism.
Either I'm getting your approach wrong or I'm too tired, but if you want to trigger a run event you should avoid the activated signal completely. Set the signal slot mechanism so that your double click and Enter key press event trigger your run() function, and then the single click/nav buttons should trigger the 'activated' slot which will return your index in the tableview.
I'm pretty certain Qt wants you to be explicit about which signal points to which slot or it'll ignore it or point to a default.

Setting Record Data resets ToggleButton

I am facing a strange problem.
I have created a normal ext-gwt grid with two columns. One column displays a number and the other renders a ToggleButton. As soon as the ToggleButton gets pressed a small window appears with: 1- a textfield (to enter a number), 2- an ok button.
When the ok button is pressed the column containing the number should change it's value to the value given in the small window's textfield. This is the final picture I want to have. Easy! right?
The problem comes now. This is what is executed when the ok button is pressed in order to change the value in the column:
Integer value = new Integer(10);
Record record = store.getRecord(bean);
record.set("employeeNumber", value);
Although the value is actually changed using this code, it makes something weird. The ToggleButton remains in the "un-pressed" state whenever this code is executed. If I remove the last line, the ToggleButton functions normally again (gets pressed).
Any idea how to solve the problem of the ToggleButton?
Thank you
So you want the toggle button to change state after setting the value, right?
How do you get the toggle button into the grid?
I assume by using a custom widget renderer? In this case the render(..) method will be called more than once, returning a fresh and un-toggled button each time which will be displayed...
Maybe you could post some more code...?

Resources