How to programmatically press toolstripbutton down? - checked

I want to push toolstripbutton down in my code and I can't seem to be able to do that. I know on Delphi RAD Studio or XE, you can do the following and cause the button to be pressed.
ToolStripButton1.Down := true;
The only ToolStripButton property I see that comes close to "down" is checked true or false. If I do set it to true, it only highlights the toolstripbutton not press it down.
Here is how the button looks when I put my mouse on it and click:
You can clearly see that the Zoom In button is down.
Here is how the button looks when I try to do the samething through my code by setting CheckOnClick true and Checked true.
In this image, the only thing you can see is the blue box around it. I suppose if I had used just the text on the button, you will see that the whole button filled with blue color to show that it was pressed.
I also have toolstrip button in my other program which acts the same way but I had to use imagelist control to switch between pressed or down or checked verses not pressed or down or checked.
So, is there a way to press the ToolStripButton programmatically in Delphi Prism or C#?

Set the ToolStripButton.CheckOnClick property to True. (It's found in the Behavior section of the Items Collection Editor.)
This makes clicking it just like toggling the Down property in a Delphi TSpeedButton (making it flat or depressed), and if ToolStripButton1.Checked is the equivalent of if SpeedButton1.Down in Delphi.
To set up the test, I did the following:
Created a new Winforms application
Dropped a ToolStrip onto the new MainForm
Added four ToolStripButton items and gave them images to make them easier to see.
Set the CheckOnClick property to True for each of them
Set the Checked property of toolStripButton1 to True;
Added the code below to toolStripButton1.Click
method MainForm.toolStripButton1_Click(sender: System.Object; e: System.EventArgs);
begin
toolStripButton2.Checked := not toolStripButton2.Checked;
toolStripButton4.Checked := toolStripButton2.Checked;
end;
Running the app (initial startup, toolStripButton1 checked and the others unchecked):
The first button is clearly down, and the rest are up.
After clicking toolStripButton1 once:
The first button is now up (unchecked) and the second and fourth are down (checked). (I should pay more attention to the consistency in sizing if I do successive images in future posts.)

If have placed this code in the preceding control in the 'Leave' event.
Private Sub PurposeComboBox_Leave(sender As Object, e As EventArgs) Handles PurposeComboBox.Leave
Me.AppliancesForSelectedFunctionToolStripButton.PerformClick()
End Sub
I do not know if you could place code in Form Load or not.
Hope this helps.

Related

Powerapps - Unable to change Toggle on separate screen

I'm trying to use toggles on an inactive screen as a replacement for functions (and thus help code reuse), however I'm stuck as my toggle won't activate unless I visit the page it's on. I found plenty of working examples online but somehow can't get it to work for me.
Overview:
I have a button on screen1 and a toggle on screen2.
During my button's OnSelect event, a variable varSendData is being set to true like so:
Set (varSendData, true)
The toggle has its Default property set to varSendData.
The OnCheck property of the toggle contains the code to be executed:
Notify("This works")
Problem:
While the variable varSendData is correctly being set to true, nothing happens while I'm on the screen1 with the button. Only when I visit the screen2 with the toggle (even if in edit mode only) does the toggle change state and execute the code in the OnCheck property. I tried using the OnChange property of the toggle, however that has the same effect/limitation.
Furthermore, if I set the variable (varSendData) back to false before visiting screen2 then nothing happens from which I conclude that the toggle is only triggered (changed) if the page it's on is visible/active.
Any ideas on how I could get the toggle to change state even if I'm not screen2? Or any other ideas on how I could reuse the same code from different screens?
It's a limitation of the method the actual code is calling. In order to allow the HTML to refresh from this "Notify("This Works"). You would need to also have a function that refreshes the HTML in the screen your currently viewing.
I was able to get this to work by adding a label and setting its text property to be If(Toggle6.Value = true, "yes", "no").
Literally adding this in allowed the notification to pop up. Nothing extra.

Multiple delphi forms

I have two delphi forms; frmHome and frmStats. There is a button on the main form (frmHome) and when you click on it it takes you to frmStats.
On btn click in frmHome:
frmStats.ShowModal;
Hide;
This works fine but on frmStats there is also a button that I would like to take the user back to the main form when clicked on. The problem is I get error messages.
If I make reference to the form like this I get the error message "cannot make visable window modal"
implementation
uses frmHome_u;
However if I make reference like this, then i get the message "circular unit reference"
interface
uses {a bunch of uses} , frmHome_u;
On btn click in frmStats:
frmHome.ShowModal;
Hide;
How do I do this?
Modal forms have owners. These owning forms are disabled when the modal form is shown. A form is always shown above its owner.
You are trying to make form1 be the owner of form2 and then in turn have form2 own form1. That circular ownership is not allowed. It would imply that both windows would be disabled, and each window on top of the other.
What you need to do is to close the modal form. Replace
frmHome.ShowModal;
Hide;
with
ModalResult := mrOK;
If you want both forms to be visible and enabled at the same time, then you must not show them modally.
If I understand what you are trying to do then this should work just fine.
frmStats.Enabled := True;
frmStats.Show;
Enabled := False;
Hide;
And you have the reciprocal code in the other form.
Because the other form is disabled, it can not be brought into focus until you enable it.
EDIT
If the users closes FrmStats and FrmHome is the mainform then you must enable it in the onclose event.

Google Closure add onclick to button after adding this button with custom editor plugin

I am making a custom plugin for the editor provided by Google Closure. The plugin makes it able to add a button.
I am having problems by setting an onclick on the button, the other values are nicely set.
button.innerHTML = event.label;
button.className = event.initialClass;
var extraClasses = event.extraClasses;
if (extraClasses)
{
button.className += ' ' + extraClasses
}
button.onclick = function() { event.onclick };
Does anyone know what I am doing wrong and how I can fix this?
After creating a button it is added to the editors SeamlessField. A second problem that I currently have is that after creating the button, my pointer is inside the button and I can't seem to get it out of there.
I've got the follow piece of code for handling this at the moment. The var button is the created button. button contains: <button class="orange">test</button>
// We want to insert the button in place of the user's selection.
// So we restore it first, and then use it for insertion.
this.restoreOriginalSelection();
var range = this.fieldObject.getRange();
button = range.replaceContentsWithNode(button);
// Done making changes, notify the editor.
this.fieldObject.dispatchChange();
// Put the user's selection right after the newly inserted button.
goog.editor.range.placeCursorNextTo(button, false);
// Dispatch selection change event because we just moved the selection.
this.fieldObject.dispatchSelectionChangeEvent();
Any ideas about how I could fix this second problem aswell?
For the first, it does not look like you have begun using Google Closure event code. Wiring up the button to the 'click' event in Google Closure would be as follows:
goog.events.listen(button, goog.events.EventType.CLICK, event.onclick)
You should also be investigating the goog.dom and goog.dom.classes namespaces if you'd like to use Google Closure's wrappers around standard CSS class and text DOM manipulation.
For the second, were you testing in Chrome? If so, you might have ran into a range issue in Webkit, documented within the Closure code itself:
https://code.google.com/p/closure-library/source/browse/closure/goog/editor/range.js#174
I have gotten around this in the past by inserting an empty <span> element as a sibling after the offending element (the button, in your case), and placing the cursor next to the <span> instead. However, there's nothing stopping the user from moving the cursor back inside your button. You'll have to add more logic to prevent a user from placing the cursor within the button's text.

ImgButton : How to tell SmartGWT to not concatene state on the name of file source?

private ImgButton button = new ImgButton();
...
button.setSrc("iconName.jpg");
GWT or SmartGWT, I cannot tell exactly, generate state word to concatene it on the name of file.
Example to clarify :
On focus, iconName.jpg become iconName_Focus.jpg
On mouse down click, iconName.jpg become iconName_Down.jpg
On over, iconName.jpg become iconName_Over.jpg
Because these images are custom images, I want to tell GWT to take a default image when I didn't provide the corresponding image.
For example, when over event is fire and iconName_Over.jpg does not exist then use iconName.jpg.
Use the setShow{State} or setShow{State}Icon methods accordingly. For example for disabling the mouse down state, use setShowDown(Boolean.FALSE). For not showing a different icon when the mouse goes down on the button, use the setShowDownIcon(Boolean.FALSE). The rest of the actions have accordingly named methods you can look up at the ImgButton's javadoc page.

Is there a simple source code viewer plugin for eclipse?

for example
setMediamixDefaultTime(mediamixVO);
boolean booked = false;
Long campaignSeq = mediamixVO.getCampaignSeq();
when I want to know about how to declared setMediamixDefaultTime() method,
I have to jump to setMediamixDefaultTime() declaration line.
It's very annoying especiouly source code is long..
so I need that is,
if I move mouse to that method or keyboard shortcut, the method declaration popup in small window.
just crtl+click on the item you want to jump to.
There is also an outline view, which shows the program structure.
Control + mouse click on the method will take you to the method declartion and you can use the back button to come back to the previous code.
Again the shortcut for back button is Alt + left arrow
You can make use of the Declaration View if you don't want to lose your place, but the Navigate menu's "Last Edit Location", Back, and Forward actions may also work.