NSAlert runModal in outlineView:acceptDrop crashes with may not be invoked inside of transaction begin/commit pair

2020-10-31 Thread Michael Kloske via Cocoa-dev

Hello,

I have an OutlineView. Whenever I drag and drop a child item within the 
Outline-View my application crashes when I open do an "NSAlert runModal" 
like in the code below:


- (BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id < 
NSDraggingInfo >)info item:(id)item childIndex:(NSInteger)index

{
    ...
1    if(needToAskUser)
 {
2    NSAlert *alert = [[NSAlert alloc] init];
3    // .. set some texts and buttons in alert
4       [alert runModal];
 }
}

In line 4 the app crashes with the following uncaught exception:
[General] -[NSAlert runModal] may not be invoked inside of transaction 
begin/commit pair, or inside of transaction commit (usually this means 
it was invoked inside of a view's -drawRect: method.)


I have a tree like this:
Top Level 1
  - Child Item A
  - Child Item B
Top Level 2
  - Child Item C
...

The problem occurs only, when I drag one of the Child Items within the 
same view. It does not matter whether I move Child Item A below Child 
Item B or if I move it to another Top Level item, for example below 
Child Item C.


Moving the block into a call to 
dispatch_async(dispatch_get_main_queue(), ^{ }); did also not help.


Has anyone any idea what the problem is?
Best regards,
Michael Kloske

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Drag and Drop of NSTokenField stopped working in Catalina

2020-07-01 Thread Michael Kloske via Cocoa-dev


On 06/30/20 18:46, James Walker via Cocoa-dev wrote:


My code (working in Catalina) is

- (BOOL)tokenField:(NSTokenField *)tokenField
  writeRepresentedObjects:(NSArray *)objects
  toPasteboard:(NSPasteboard *)pboard
{
  [pboard clearContents];
  return [pboard writeObjects:objects];
}


This works for me. Thanks a lot.
Best regards, Michael Kloske

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Drag and Drop of NSTokenField stopped working in Catalina

2020-06-30 Thread Michael Kloske via Cocoa-dev
>> in my application I have several NSTokenField - objects that are used to 
>> drag them into a text field to build up a string by some tokens.
>> However, since Catalina dragging of those NSTokenField - objects does not 
>> work anymore.
>> In Xcode I get the following message:
>> 
>> ": There was an exception (There are 
>> 2 items on the pasteboard, but 1 drag images. There must be 1 draggingItem 
>> per pasteboardItem.) raised while processing drag. Ignoring…”
> 
> 
> The NSTokenField is used in the Mail application in the address field. Using 
> the Mail app in Catalina, drag a token from the address field to a TextEdit 
> document. Does that work?
> 
> I would try it but my primary development machine is macOS Sierra.
> 

This works pretty well. If writableTypesForPasteboard returns just nil, it 
would also work in my application but then I would miss my internal data.


—Michael Kloske

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Drag and Drop of NSTokenField stopped working in Catalina

2020-06-30 Thread Michael Kloske via Cocoa-dev
Hello,

in my application I have several NSTokenField - objects that are used to drag 
them into a text field to build up a string by some tokens.
However, since Catalina dragging of those NSTokenField - objects does not work 
anymore.
In Xcode I get the following message:

": There was an exception (There are 2 
items on the pasteboard, but 1 drag images. There must be 1 draggingItem per 
pasteboardItem.) raised while processing drag. Ignoring…”


For handling the paste board writing I have the following code in my token 
objects which implement :

- (NSArray *)writableTypesForPasteboard:(NSPasteboard *)pasteboard
{
return @[ @“" ];
}

In my window controller, which implements  I have the 
following code:

- (BOOL)tokenField:(NSTokenField *)tokenField
writeRepresentedObjects:(NSArray *)objects
  toPasteboard:(NSPasteboard *)pboard
{
return [pboard writeObjects:objects];
}

As I said it worked pretty well until (including) Mojave but stopped working in 
Catalina with the above error message.

As I saw in addition to my “my.unique.UTI.id ” the 
TokenField seems to add “utf-8.string” as item as well, that’s why the 
pasteboard will have two items instead of one.

Has anyone any idea how to fix that issue?

Best regards,
Michael
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com