Why does the first button pressed shrink in codenameone? - codenameone

I am a novice programmer working on a project that has buttons change color when pressed (among other things). I am having a problem that the first button I click shrinks (the padding increases?) when it is clicked, but it still works and does everything it is supposed to. I have tried looking through theme.res to find a way to stop the button from shrinking when pressed and I have tried looking for an answer online, but have not found a solution. Thanks!

In the Resource Editor(theme.res), go to "Themes" -> "Unselected" tab. Right click over the style you use for the button and press Derive All.

Related

How know if right click is on a "text being edited" not/before "text changed" event in winforms?

My question might be simple but I couldn't find specific answer on web.
I have a winforms application with a grid inside, in which I have implemented a context menu to be shown on right click on cells. These cells include text elements that can be edited. When user clicks or double clicks on the cell, the text can be edited and that's what I want. The problem is when the text is in edit mode and user right clicks on it again, 2 context menus are shown on each other. One is my context menu and the other is windows right click on text including options like copy, paste etc.
I wonder if there is any event like "text being edited" or "windows default context menu opened" that can be used for such scenarios? Or what is the proper way of solving this problem, which I guess must be a common one.
In these cases I want to show only the windows right-click menu, not mine.
Perhaps you need the Control.GotFocus event: https://msdn.microsoft.com/en-us/library/system.windows.forms.control.gotfocus%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396
You could look for focus, then prevent right clicks in the control until the control has lost focus (Control.LostFocus). If the control gets focus from a right click, then you could open your context menu (I think).

Is it possible to setup a toggle button when includeNativeBool is set to false?

According to the Developer Guide, to make a toggle button I should run setToggle(true) on a CheckBox. I couldn't get that to work at first, so I tried on a new theme and it worked just fine. After some experimentation I found that this only happens when includeNativeBool constant is set to false.
When I press the button, it changes to the pressed state, but when I release it, it changes back to the unselected/selected state. However, when I press it a second time, it doesn't change to the pressed state at all (maybe because it's internally "checked" already), and when I release it nothing happens. When I press it a third time, it behaves like the first, and so on.
I suggest not removing the includeNativeBool, you will run into basic complexities.
The toggle button works just as well without includeNativeBool but the the styles for ToggleButton won't be in the theme. Assuming you styled Button just use setUIID("Button");

Text blurring at any text options

After clicking, for example, on a button with no handler (that is no any reation axcept button clicking animation) I have this ugly effect on my eyes:
Blurring of the text on the button goes off in a second (from the first picture to the second and so on to the sharpness), then the text gets sharpness. I have this effect at any combinations of "TextOptions" options in XAML including TextOptions.TextFormattingMode="Display".
If I click on a button which raises, for example, select file dialog window, everything seems well.
How to escape this blur? Have you ever seen this effect?
In addition. This effect appears only with TextSize=11 and Aero is disabled. With TextSize equals any another value all goes well. But 11 is a default value so everybody can see this bug!
I don't know if you've fixed this yet or not, but the solution is to use the flag UseLayoutRounding="True". Throw that on the button style and it will be fixed.

Google like SearchBox in Silverlight

I've created a Google like SearchBox control in Silverlight. That means, as I type in the box, a DropDownListBox appears just below the SearchBox, showing all the items that match with the text I've typed in searchbox so far (i.e AutoComplete feature), exactly like this:
Now, I want to add a functionality to it : I want to make the DropDownListBox to disappear, as soon as user clicks outside it, or anywhere on the screen. I cannot handle MouseLeftButtonDown (or any such event) in other controls, to accomplish this, because users can click anywhere, including non-silverlight region. Can anybody suggest me what should I do to achieve this?
So my question basically is:
How to know if user has just clicked and the click event occurred outside a particular control?
Please note that AutoCompleteBox doesn't serve my purpose. So I cannot use it.
I have a feeling that working with LostFocus event can solve your problem.
I guess this question is a bit old, but i just stumble upon trying to do the same and finding a solution. This is what i did
Created a Border with All Margins -500, this will cover the full screen essentially.
On Click Behaviour of this Border, the dropdown section of SearchBox
is collapsed.
Adjust z-Index of Border just below the SearchBox and DropDown
section, so clicking on SearchBox or DropDown wouldn't close it.
Set Border Visibility Collapsed, and make it visible when DropDown is Visible.
I hope it helps someone who is looking for the similar problem.

Show NotifyIcon Context Menu and Control Its Position?

I'm trying to show a context menu when I left-click a NotifyIcon. Just calling NotifyIcon.ContextMenuStrip.Show() doesn't work very well. A solution has been posted here before that calls a secret method using Reflection:
Dim mi As System.Reflection.MethodInfo = GetType(NotifyIcon).GetMethod("ShowContextMenu", Reflection.BindingFlags.Instance Or Reflection.BindingFlags.NonPublic)
mi.Invoke(Icon, Nothing)
This works great, except that I also need to control where the menu is shown. I want to wait for the SystemInformation.DoubleClickTime to elapse between receiving the NotifyIcon.MouseUp event and displaying the menu, so that I can handle single-clicks and double-clicks separately. But invoking the ShowContextMenu method displays the menu at the current mouse position when ShowContextMenu is called, not when the icon was actually clicked. Which means that if the mouse moved during the DoubleClickTime, the menu will be displayed in a different part of the screen. So if I can control where the menu is shown, I can just save the mouse coordinates when I receive the MouseUp event, and then I can ensure that the menu is displayed near the icon. Is there a way to do this?
Thanks in advance.
Well, I just discovered that there are existing programs that exhibit this same behavior. I just went through all the icons in my system tray and about half of them do it. If you left-click the icon and then move the mouse during the delay before the menu appears, the menu will appear at the last mouse location, wherever that is on the screen. Snagit is one application that does this. Outlook is the only program in my tray that always shows the menu where I clicked the icon. But Snagit looks like it's using a .NET ContextMenuStrip, while Outlook is probably using a native menu.
So either this is standard behavior, or it's a problem that no one else has been able to solve either. And as a user, I've never noticed this behavior until yesterday when I was testing my own application. So I guess it's not that big of a deal and I won't worry about it.

Resources