On macOS, SwiftUI Menu buttons appear initially disabled. Once you click on them, they activate as normal and display properly. This code replicates the problem:
Menu {
Button("First") { }
Button("Second") { }
} label: {
Image(systemName: "gearshape.fill")
}
.padding()
Which initially will look like this:
Then after clicking on the button:
Preview shows correctly, but a running app behaves as above
The contents of the menu don't seem to affect the result
Tried explicitly mucking with disabled state using .disabled(false); no joy since it isn't really disabled
I could just set the foreground color of the image, but I was hoping to figure out the real problem. Am I missing something?
EDIT: Setting the foreground doesn't work either. Still visibly disabled.
This bug (filed as FB8976414) remains as of macOS 11.3. I got some help from #kontiki on a workaround, though. If you include a Button along with the Menu, it displays properly enabled. Don't ask me why. You can make the Button zero-sized so it doesn't affect your layout and just remove it when (if?) the bug gets fixed.
-- Update --
As of macOS 11.4, this technique no longer works. The Menu always displays as disabled until it's clicked. I guess if you look on the bright side, at least it's more consistent!
-- --
HStack(spacing: 0) {
Menu {
Button("First") { }
Button("Second") { }
} label: {
Image(systemName: "gearshape.fill")
}
Button("", action: {}).scaleEffect(x: 0, y: 0)
}
-- Update 2 --
As of macOS 12.0 according to #Taylor (verified by me in macOS 12.1), the bug is fixed. Thanks, Apple engineers!
Related
Samsung started using WearOS in their latest smartwatches, e.g. in Galaxy 4 watch, and I need to test bezel functionality since the latter model does have it. However I didn't find any WearOS devices in AVD supporting bezel.
I've also tried creating a new h/w profile, but didn't find a bezel option there either. All navigation options they have are below. None of them is related to bezel.
I've also tried to find a skin for Galaxy 4, but with no luck so far. The code that doesn't work according to a Galaxy4 owner is below. You can suggest how to fix the code of course, but I still want to know how to test it without buying a watch
view.setOnGenericMotionListener { v, ev ->
if (ev.action == MotionEvent.ACTION_SCROLL &&
ev.isFromSource(InputDeviceCompat.SOURCE_ROTARY_ENCODER)
) {
val delta = -ev.getAxisValue(MotionEventCompat.AXIS_SCROLL) *
ViewConfigurationCompat.getScaledVerticalScrollFactor(
ViewConfiguration.get(this), this
)
if (Math.abs(delta) > 2f) {
val np = if (delta > 0) Util.nextAccount(mAccount) else Util.prevAccount(mAccount)
Util.d(TAG, mAccount + np.toString())
switchAccount(np)
}
true
} else {
false
}
}
nextAccount and prevAccount are some custom functions that switch the view. None of them is called according to a user.
Here is a Tizen Studio emulator with a bezel that can be rotated by dragging the white dot:
I've finally fixed the problem. In a view's layout that is supposed to process the rotary event I've added requestFocus tag:
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:scrollbars="vertical"
android:fadeScrollbars="false"
android:id="#+id/token_scroll"
>
<requestFocus />
...
To test the bezel, I've used menu on the right of the emulator as shown on the picture below. Bezel events are processed correctly at least in the emulator. I'll let you know if it works in real Galaxy 4 smartwatch when hear from the user.
UPDATE
A Galaxy 4 smartwatch user has just confirmed that bezel works after the fix. It confirms that both the fix and the testing method were correct and achieved their goals.
I have a problem with my application and his navigation.
My app have four screens but sometimes when tap the android home button in the second screen (or any other) and after resume the app, this show the home screen and not the last screen, any ideas to resolve this?
Update:
Sometimes after resume the app, this show the correct screen (the last showed) but I don't know how this happen (it's the same source code), I tested this in many versions of android simulator (4.4, 5.0, 7.0 y 8.0). Can this be a bug?
Screen Recording:
https://i.imgur.com/VhWFhWU.gifv
Code:
https://play.nativescript.org/?template=play-vue&id=wKkYCe&v=2
Thanks
It should be easy if you are using single frame in your application. You could listen to resume event of activity and call $navigateBack with a reference to first item in the back stack.
if (application.android) {
application.android.on(application.AndroidApplication.activityResumedEvent,
() => {
const backStack = frame.topmost().backStack[0];
if (backStack) {
setTimeout(() => {
this.$navigateBack({}, backStack);
}, 0);
}
}, this);
}
Playground Sample
I am working on an Today Extension for Yosemite.
I would like to show a SettingsViewController instead of going into edit mode.
If I "presentViewControllerInWidget" on "widgetDidBeginEditing" it gets some weird glitches and the view controller is hiding and showing all the time.
Did anyone achieved to show an viewController on info button click or knows a workaround on that glitch?
func widgetDidBeginEditing() {
self.presentViewControllerInWidget(self.settingsViewController)
}
This worked for me:
func widgetDidBeginEditing() {
var delay = dispatch_time(DISPATCH_TIME_NOW, Int64(0.1 * Double(NSEC_PER_SEC)))
dispatch_after(delay, dispatch_get_main_queue()) {
self.presentViewControllerInWidget(self.settingsViewController)
}
}
I guess this is a bug that made it into the Yosemite release.
Documentation on widgets is very sketchy at best and it seems there are quite a few oddities in the framework.
When adding a symbolic breakpoint to widgetDidBeginEditing I get two hits when clicking the little edit button, and the edit Button becomes "Cancel". It is supposed to say "Done" though. Only after an "Add" action should it say "Cancel" (Just check out Apple's Weather widget)
Important to say: I am not using the template with the NCWidgetListViewController but my own list implementation.
If anyone finds a proper solution to this problem I'd be very happy!
I have set enableTextSelectionOnCells according to SlickGrid and Text Selection.
I am not really happy about it.
Cell text gets selected with a bad behaviour. Sometimes as soon as selection is done, the selection disappears. Only on rare occasions does it work.
Has anyone faced this issue?
I have tried this on Firefox and Chrome.
to reproduce:
git clone git#github.com:mleibman/SlickGrid.git
go to examples folder
edit the example1-simple.html
Add enableTextSelectionOnCells: true in options
Open example1-simple.html in FF/Chrome
Try selecting a cell value
FYI, I am running on Ubuntu if it should make any difference.
This problem is already solved on Github. You just have to modify slick.gird.js. Around line number 2270, you just have to add " options.editable && ". Hope this help.
if (!currentEditor) {
// if this click resulted in some cell child node getting focus,
// don't steal it back - keyboard events will still bubble up
// IE9+ seems to default DIVs to tabIndex=0 instead of -1, so check for cell clicks directly.
if (options.editable && e.target != document.activeElement || $(e.target).hasClass("slick-cell")) {
setFocus();
}
}
I have a page with a Pivot, with TextBox controls. In landscape, the SIP (the virtual keyboard) is opffsetted right by 42 pixels, thus clipped to its right.
Another app of mine also has a similar page, without the offsetted keyboard problem. Before I dig more into the differences between the two, has anyone ever encountered this problem before? Can we consider this a bug with Windows Phone 7.1?
(it does occur on a real device too)
It is a bug in windows phone:
If you set the Mode property on the app bar to Minimised and then turn the thing to landscape, the app bar pops back out. The code that figures out where to show the keyboard doesn't realise this and displays the keyboard as if the app bar is still minimised.
I solved it by changing the mode of the app bar as the orientation changes:
private void phoneApplicationPage_OrientationChanged(object sender, OrientationChangedEventArgs e)
{
if (e.Orientation == PageOrientation.LandscapeLeft || e.Orientation == PageOrientation.LandscapeRight)
{
this.ApplicationBar.Mode = Microsoft.Phone.Shell.ApplicationBarMode.Default;
}
else
{
this.ApplicationBar.Mode = Microsoft.Phone.Shell.ApplicationBarMode.Minimized;
}
}
This seems to solve the problem
Try checking if you have a set common right offset margin somewhere in your code. That is the most likely reason for this behavior.
I have never experienced this error myself.